summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2021-03-16 12:25:34 -0400
committerEric Lin <anselor@gmail.com>2021-03-18 14:16:03 -0400
commit0cd626ebbef273aa78c2d1154ebdd5f9055028cf (patch)
tree9a822b245312b3b515b64a69d772fab75fce8121 /examples
parenta649286b9468ebadbafeca1abf20a946351ceefe (diff)
downloadcmd2-git-cmdset_settables.tar.gz
Resolves comments from PRcmdset_settables
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/cmd_as_argument.py2
-rwxr-xr-xexamples/colors.py2
-rwxr-xr-xexamples/decorator_example.py2
-rwxr-xr-xexamples/environment.py6
-rwxr-xr-xexamples/example.py2
-rwxr-xr-xexamples/first_app.py2
-rwxr-xr-xexamples/initialization.py2
-rwxr-xr-xexamples/pirate.py2
-rwxr-xr-xexamples/plumbum_colors.py6
9 files changed, 14 insertions, 12 deletions
diff --git a/examples/cmd_as_argument.py b/examples/cmd_as_argument.py
index 951c54b9..33ad699b 100755
--- a/examples/cmd_as_argument.py
+++ b/examples/cmd_as_argument.py
@@ -36,7 +36,7 @@ class CmdLineApp(cmd2.Cmd):
self.self_in_py = True
self.maxrepeats = 3
# Make maxrepeats settable at runtime
- self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command'))
+ self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command', self))
speak_parser = argparse.ArgumentParser()
speak_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
diff --git a/examples/colors.py b/examples/colors.py
index abfb8955..2cdd047d 100755
--- a/examples/colors.py
+++ b/examples/colors.py
@@ -49,7 +49,7 @@ class CmdLineApp(cmd2.Cmd):
self.maxrepeats = 3
# Make maxrepeats settable at runtime
- self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command'))
+ self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command', self))
# Should ANSI color output be allowed
self.allow_style = ansi.STYLE_TERMINAL
diff --git a/examples/decorator_example.py b/examples/decorator_example.py
index 09193926..9497bcc0 100755
--- a/examples/decorator_example.py
+++ b/examples/decorator_example.py
@@ -31,7 +31,7 @@ class CmdLineApp(cmd2.Cmd):
self.maxrepeats = 3
# Make maxrepeats settable at runtime
- self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command'))
+ self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command', self))
# Example of args set from the command-line (but they aren't being used here)
self._ip = ip_addr
diff --git a/examples/environment.py b/examples/environment.py
index 5f5d927b..151c55af 100755
--- a/examples/environment.py
+++ b/examples/environment.py
@@ -13,8 +13,10 @@ class EnvironmentApp(cmd2.Cmd):
super().__init__()
self.degrees_c = 22
self.sunny = False
- self.add_settable(cmd2.Settable('degrees_c', int, 'Temperature in Celsius', onchange_cb=self._onchange_degrees_c))
- self.add_settable(cmd2.Settable('sunny', bool, 'Is it sunny outside?'))
+ self.add_settable(
+ cmd2.Settable('degrees_c', int, 'Temperature in Celsius', self, onchange_cb=self._onchange_degrees_c)
+ )
+ self.add_settable(cmd2.Settable('sunny', bool, 'Is it sunny outside?', self))
def do_sunbathe(self, arg):
"""Attempt to sunbathe."""
diff --git a/examples/example.py b/examples/example.py
index ffa8d3bf..a3d4e90b 100755
--- a/examples/example.py
+++ b/examples/example.py
@@ -32,7 +32,7 @@ class CmdLineApp(cmd2.Cmd):
# Make maxrepeats settable at runtime
self.maxrepeats = 3
- self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command'))
+ self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command', self))
speak_parser = argparse.ArgumentParser()
speak_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
diff --git a/examples/first_app.py b/examples/first_app.py
index 0b088491..b6335e25 100755
--- a/examples/first_app.py
+++ b/examples/first_app.py
@@ -27,7 +27,7 @@ class FirstApp(cmd2.Cmd):
# Make maxrepeats settable at runtime
self.maxrepeats = 3
- self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command'))
+ self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command', self))
speak_parser = argparse.ArgumentParser()
speak_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
diff --git a/examples/initialization.py b/examples/initialization.py
index 293d8075..54bef6d8 100755
--- a/examples/initialization.py
+++ b/examples/initialization.py
@@ -51,7 +51,7 @@ class BasicApp(cmd2.Cmd):
# Make echo_fg settable at runtime
self.add_settable(
- cmd2.Settable('foreground_color', str, 'Foreground color to use with echo command', choices=fg.colors())
+ cmd2.Settable('foreground_color', str, 'Foreground color to use with echo command', self, choices=fg.colors())
)
@cmd2.with_category(CUSTOM_CATEGORY)
diff --git a/examples/pirate.py b/examples/pirate.py
index 7b92b6f0..f91b99d7 100755
--- a/examples/pirate.py
+++ b/examples/pirate.py
@@ -28,7 +28,7 @@ class Pirate(cmd2.Cmd):
self.songcolor = 'blue'
# Make songcolor settable at runtime
- self.add_settable(cmd2.Settable('songcolor', str, 'Color to ``sing``', choices=cmd2.ansi.fg.colors()))
+ self.add_settable(cmd2.Settable('songcolor', str, 'Color to ``sing``', self, choices=cmd2.ansi.fg.colors()))
# prompts and defaults
self.gold = 0
diff --git a/examples/plumbum_colors.py b/examples/plumbum_colors.py
index a7cb7e88..16326569 100755
--- a/examples/plumbum_colors.py
+++ b/examples/plumbum_colors.py
@@ -62,11 +62,11 @@ class BgColors(ansi.ColorBase):
purple = bg.Purple
-def get_fg(name: str):
+def get_fg(name: str) -> str:
return str(FgColors[name])
-def get_bg(name: str):
+def get_bg(name: str) -> str:
return str(BgColors[name])
@@ -83,7 +83,7 @@ class CmdLineApp(cmd2.Cmd):
self.maxrepeats = 3
# Make maxrepeats settable at runtime
- self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command'))
+ self.add_settable(cmd2.Settable('maxrepeats', int, 'max repetitions for speak command', self))
# Should ANSI color output be allowed
self.allow_style = ansi.STYLE_TERMINAL