summaryrefslogtreecommitdiff
path: root/examples/initialization.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/initialization.py')
-rwxr-xr-xexamples/initialization.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/initialization.py b/examples/initialization.py
index dfea2183..375711ff 100755
--- a/examples/initialization.py
+++ b/examples/initialization.py
@@ -14,8 +14,8 @@
"""
import cmd2
from cmd2 import (
- bg,
- fg,
+ StdBg,
+ StdFg,
style,
)
@@ -32,7 +32,7 @@ class BasicApp(cmd2.Cmd):
)
# Prints an intro banner once upon application startup
- self.intro = style('Welcome to cmd2!', fg=fg.red, bg=bg.white, bold=True)
+ self.intro = style('Welcome to cmd2!', fg=StdFg.RED, bg=StdBg.WHITE, bold=True)
# Show this as the prompt when asking for input
self.prompt = 'myapp> '
@@ -47,11 +47,12 @@ class BasicApp(cmd2.Cmd):
self.default_category = 'cmd2 Built-in Commands'
# Color to output text in with echo command
- self.foreground_color = 'cyan'
+ self.foreground_color = StdFg.CYAN.name.lower()
# Make echo_fg settable at runtime
+ fg_colors = [c.name.lower() for c in StdFg]
self.add_settable(
- cmd2.Settable('foreground_color', str, 'Foreground color to use with echo command', self, choices=fg.colors())
+ cmd2.Settable('foreground_color', str, 'Foreground color to use with echo command', self, choices=fg_colors)
)
@cmd2.with_category(CUSTOM_CATEGORY)
@@ -62,7 +63,8 @@ class BasicApp(cmd2.Cmd):
@cmd2.with_category(CUSTOM_CATEGORY)
def do_echo(self, arg):
"""Example of a multiline command"""
- self.poutput(style(arg, fg=self.foreground_color))
+ fg_color = StdFg[self.foreground_color.upper()]
+ self.poutput(style(arg, fg=fg_color))
if __name__ == '__main__':