diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-02-20 22:56:25 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-02-20 22:56:25 -0500 |
commit | 6cb882e3420fef1497955c9b4c7f0d8674e1557d (patch) | |
tree | 0256863a9846acd5001ab6a97b1756a54ccd3df7 /examples | |
parent | 6e4d4801827559b3dc150b1dd29de482cfba2626 (diff) | |
download | cmd2-git-6cb882e3420fef1497955c9b4c7f0d8674e1557d.tar.gz |
Changed examples to reflect that settable doesn't need to be updated before calling init()
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/cmd_as_argument.py | 6 | ||||
-rwxr-xr-x | examples/colors.py | 6 | ||||
-rwxr-xr-x | examples/decorator_example.py | 6 | ||||
-rwxr-xr-x | examples/environment.py | 2 | ||||
-rwxr-xr-x | examples/example.py | 6 | ||||
-rwxr-xr-x | examples/pirate.py | 7 | ||||
-rwxr-xr-x | examples/plumbum_colors.py | 6 |
7 files changed, 25 insertions, 14 deletions
diff --git a/examples/cmd_as_argument.py b/examples/cmd_as_argument.py index 070a34a0..dcec81c8 100755 --- a/examples/cmd_as_argument.py +++ b/examples/cmd_as_argument.py @@ -33,13 +33,15 @@ class CmdLineApp(cmd2.Cmd): self.multiline_commands = ['orate'] self.maxrepeats = 3 - # Add stuff to settable and shortcuts before calling base class initializer - self.settable['maxrepeats'] = 'max repetitions for speak command' + # Add stuff to shortcuts before calling base class initializer self.shortcuts.update({'&': 'speak'}) # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=False) + # Make maxrepeats settable at runtime + self.settable['maxrepeats'] = 'max repetitions for speak command' + speak_parser = argparse.ArgumentParser() speak_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay') speak_parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE') diff --git a/examples/colors.py b/examples/colors.py index 2641ae44..62df54e6 100755 --- a/examples/colors.py +++ b/examples/colors.py @@ -66,13 +66,15 @@ class CmdLineApp(cmd2.Cmd): self.multiline_commands = ['orate'] self.maxrepeats = 3 - # Add stuff to settable and shortcuts before calling base class initializer - self.settable['maxrepeats'] = 'max repetitions for speak command' + # Add stuff to shortcuts before calling base class initializer self.shortcuts.update({'&': 'speak'}) # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=True) + # Make maxrepeats settable at runtime + self.settable['maxrepeats'] = 'max repetitions for speak command' + speak_parser = argparse.ArgumentParser() speak_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay') speak_parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE') diff --git a/examples/decorator_example.py b/examples/decorator_example.py index bd9228db..5d127619 100755 --- a/examples/decorator_example.py +++ b/examples/decorator_example.py @@ -23,12 +23,12 @@ class CmdLineApp(cmd2.Cmd): self.shortcuts.update({'&': 'speak'}) self.maxrepeats = 3 - # Add stuff to settable and/or shortcuts before calling base class initializer - self.settable['maxrepeats'] = 'Max number of `--repeat`s allowed' - # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=False, transcript_files=transcript_files) + # Make maxrepeats settable at runtime + self.settable['maxrepeats'] = 'Max number of `--repeat`s allowed' + # Disable cmd's usage of command-line arguments as commands to be run at invocation # self.allow_cli_args = False diff --git a/examples/environment.py b/examples/environment.py index c45ce71c..e899cce8 100755 --- a/examples/environment.py +++ b/examples/environment.py @@ -14,9 +14,9 @@ class EnvironmentApp(cmd2.Cmd): sunny = False def __init__(self): + super().__init__() self.settable.update({'degrees_c': 'Temperature in Celsius'}) self.settable.update({'sunny': 'Is it sunny outside?'}) - super().__init__() def do_sunbathe(self, arg): if self.degrees_c < 20: diff --git a/examples/example.py b/examples/example.py index 264abd84..04727ec6 100755 --- a/examples/example.py +++ b/examples/example.py @@ -30,13 +30,15 @@ class CmdLineApp(cmd2.Cmd): self.multiline_commands = ['orate'] self.maxrepeats = 3 - # Add stuff to settable and shortcuts before calling base class initializer - self.settable['maxrepeats'] = 'max repetitions for speak command' + # Add stuff to shortcuts before calling base class initializer self.shortcuts.update({'&': 'speak'}) # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=False) + # Make maxrepeats settable at runtime + self.settable['maxrepeats'] = 'max repetitions for speak command' + speak_parser = argparse.ArgumentParser() speak_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay') speak_parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE') diff --git a/examples/pirate.py b/examples/pirate.py index 2da3fcaa..32330404 100755 --- a/examples/pirate.py +++ b/examples/pirate.py @@ -32,12 +32,15 @@ class Pirate(cmd2.Cmd): self.terminators = self.terminators + ['...'] self.songcolor = Fore.BLUE - # Add stuff to settable and/or shortcuts before calling base class initializer - self.settable['songcolor'] = 'Color to ``sing`` in (black/red/green/yellow/blue/magenta/cyan/white)' + # Add stuff to shortcuts before calling base class initializer self.shortcuts.update({'~': 'sing'}) """Initialize the base class as well as this one""" super().__init__() + + # Make songcolor settable at runtime + self.settable['songcolor'] = 'Color to ``sing`` in (black/red/green/yellow/blue/magenta/cyan/white)' + # prompts and defaults self.gold = 0 self.initial_gold = self.gold diff --git a/examples/plumbum_colors.py b/examples/plumbum_colors.py index 0cea3c10..3e5031d7 100755 --- a/examples/plumbum_colors.py +++ b/examples/plumbum_colors.py @@ -69,13 +69,15 @@ class CmdLineApp(cmd2.Cmd): self.multiline_commands = ['orate'] self.maxrepeats = 3 - # Add stuff to settable and shortcuts before calling base class initializer - self.settable['maxrepeats'] = 'max repetitions for speak command' + # Add stuff to shortcuts before calling base class initializer self.shortcuts.update({'&': 'speak'}) # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell super().__init__(use_ipython=True) + # Make maxrepeats settable at runtime + self.settable['maxrepeats'] = 'max repetitions for speak command' + speak_parser = argparse.ArgumentParser() speak_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay') speak_parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE') |