diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-01-26 22:04:54 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-01-26 22:04:54 -0500 |
commit | 2a0ded26b7af49ffd287046d89501e0c122d80ed (patch) | |
tree | dac5fdbaf341aaebc2548d41926c35b1692a330c /docs/features | |
parent | 3671619863dfc85f24d1ba9121ebd8bd3329b724 (diff) | |
download | cmd2-git-2a0ded26b7af49ffd287046d89501e0c122d80ed.tar.gz |
Improved example in initialiation docs
Diffstat (limited to 'docs/features')
-rw-r--r-- | docs/features/initialization.rst | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/docs/features/initialization.rst b/docs/features/initialization.rst index 936208f1..315709f0 100644 --- a/docs/features/initialization.rst +++ b/docs/features/initialization.rst @@ -6,7 +6,7 @@ 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: + """A simple example cmd2 application demonstrating the following: 1) Colorizing/stylizing output 2) Using multiline commands 3) Persistent history @@ -28,15 +28,27 @@ capabilities which you may wish to utilize while initializing the app:: super().__init__(multiline_commands=['echo'], persistent_history_file='cmd2_history.dat', startup_script='scripts/startup.txt', use_ipython=True) + # Prints an intro banner once upon application startup self.intro = style('Welcome to cmd2!', fg='red', bg='white', bold=True) + + # Show this as the prompt when asking for input self.prompt = 'myapp> ' + # Used as prompt for multiline commands after the first line + self.continuation_prompt = '... ' + # 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' + # Color to output text in with echo command + self.foreground_color = 'cyan' + + # Make echo_fg settable at runtime + self.settable['foreground_color'] = 'Foreground color to use with echo command' + @cmd2.with_category(CUSTOM_CATEGORY) def do_intro(self, _): """Display the intro banner""" @@ -45,7 +57,7 @@ capabilities which you may wish to utilize while initializing the app:: @cmd2.with_category(CUSTOM_CATEGORY) def do_echo(self, arg): """Example of a multiline command""" - self.poutput(arg) + self.poutput(style(arg, fg=self.foreground_color)) if __name__ == '__main__': |