diff options
| author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-10-11 15:20:46 -0400 |
|---|---|---|
| committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-10-18 13:06:20 -0400 |
| commit | f57b08672af97f9d973148b6c30d74fe4e712d14 (patch) | |
| tree | b314ff432f7d6a6657f0e8a578c6424487319204 /examples/initialization.py | |
| parent | e35ab9c169eccc7af3e4ec604e2ddd2e668bdc2c (diff) | |
| download | cmd2-git-f57b08672af97f9d973148b6c30d74fe4e712d14.tar.gz | |
Added support for 8-bit/256-colors with the cmd2.EightBitFg and cmd2.EightBitBg classes.
Added support for 24-bit/RGB colors with the cmd2.RgbFg and cmd2.RgbBg classes.
Removed dependency on colorama.
Deprecated cmd2.fg. Use cmd2.Fg instead.
Deprecated cmd2.bg. Use cmd2.Bg instead.
Changed type of ansi.allow_style from a string to an ansi.AllowStyle Enum class.
Fixed bug where using choices on a Settable didn't verify that a valid choice had been entered.
Diffstat (limited to 'examples/initialization.py')
| -rwxr-xr-x | examples/initialization.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/initialization.py b/examples/initialization.py index dfea2183..cb5afa35 100755 --- a/examples/initialization.py +++ b/examples/initialization.py @@ -14,8 +14,8 @@ """ import cmd2 from cmd2 import ( - bg, - fg, + Bg, + Fg, 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=Fg.RED, bg=Bg.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 = Fg.CYAN.name.lower() # Make echo_fg settable at runtime + fg_colors = [c.name.lower() for c in Fg] 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 = Fg[self.foreground_color.upper()] + self.poutput(style(arg, fg=fg_color)) if __name__ == '__main__': |
