-
Notifications
You must be signed in to change notification settings - Fork 127
Doc updates #799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Doc updates #799
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
12ade7b
Added documentation for empty sections of the Sphinx docs
tleonhardt f3cebff
Moved docs on "Commands at Invocation" and "Startup Script" from Misc…
tleonhardt 721cb0f
Added some clarifying extra info about using commands at invocation
tleonhardt f626c98
Created a new documentation section on "Output redirection and pipes"
tleonhardt 601b457
Improved alias documentationf
tleonhardt 34158ac
Improved macro documentation
tleonhardt bd1c666
Improved documentation for Argument Parsing and Tab-Completion
tleonhardt 7440079
Minor update to embedded python shells docs
tleonhardt ccc236f
Fixed documentation in regards to CompletionItem
tleonhardt 36796c2
Fixed typos
kmvanbrunt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ Features | |
| os | ||
| plugins | ||
| prompt | ||
| redirection | ||
| scripting | ||
| settings | ||
| shortcuts_aliases_macros | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,53 @@ | ||
| Initialization | ||
| ============== | ||
|
|
||
| Show how to properly initialize a ``cmd2`` app, showing parameters, sequencing, | ||
| etc. | ||
| Here is a basic example ``cmd2`` application which demonstrates many | ||
| capabilities which you may wish to utilize while initializing the app:: | ||
|
|
||
| #!/usr/bin/env python3 | ||
| # coding=utf-8 | ||
| """A simple example cmd2 appliction demonstrating the following: | ||
| 1) Colorizing/stylizing output | ||
| 2) Using multiline commands | ||
| 3) Persistent history | ||
| 4) How to run an initialization script at startup | ||
| 5) How to group and categorize commands when displaying them in help | ||
| 6) Opting-in to using the ipy command to run an IPython shell | ||
| 7) Allowing access to your application in py and ipy | ||
| 8) Displaying an intro banner upon starting your application | ||
| 9) Using a custom prompt | ||
| """ | ||
| import cmd2 | ||
| from cmd2 import style | ||
|
|
||
|
|
||
| class BasicApp(cmd2.Cmd): | ||
| CUSTOM_CATEGORY = 'My Custom Commands' | ||
|
|
||
| def __init__(self): | ||
| super().__init__(multiline_commands=['echo'], persistent_history_file='cmd2_history.dat', | ||
| startup_script='scripts/startup.txt', use_ipython=True) | ||
|
|
||
| self.intro = style('Welcome to cmd2!', fg='red', bg='white', bold=True) | ||
| self.prompt = 'myapp> ' | ||
|
|
||
| # Allow access to your application in py and ipy via self | ||
| self.locals_in_py = True | ||
|
|
||
| # Set the default category name | ||
| self.default_category = 'cmd2 Built-in Commands' | ||
|
|
||
| @cmd2.with_category(CUSTOM_CATEGORY) | ||
| def do_intro(self, _): | ||
| """Display the intro banner""" | ||
| self.poutput(self.intro) | ||
|
|
||
| @cmd2.with_category(CUSTOM_CATEGORY) | ||
| def do_echo(self, arg): | ||
| """Example of a multiline command""" | ||
| self.poutput(arg) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| app = BasicApp() | ||
| app.cmdloop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.