summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2020-02-06 23:52:31 -0500
committerGitHub <noreply@github.com>2020-02-06 23:52:31 -0500
commit3f075900264fee32c356aac3d03b2568664ba684 (patch)
tree81a8935b7a2b8ea1c7ba429a3bde25db9c33deee /examples
parent3c627af7c1e22bcd0cd0a49dee05fd6b626bccc5 (diff)
parent138c28d18cee56ae09416cc00d2d461e983d90e8 (diff)
downloadcmd2-git-3f075900264fee32c356aac3d03b2568664ba684.tar.gz
Merge pull request #876 from python-cmd2/color_autocomplete
Added convenience enums of fg and bg colors
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/basic.py4
-rwxr-xr-xexamples/colors.py4
-rwxr-xr-xexamples/initialization.py7
-rwxr-xr-xexamples/pirate.py2
4 files changed, 8 insertions, 9 deletions
diff --git a/examples/basic.py b/examples/basic.py
index 37db6501..5df3d1b5 100755
--- a/examples/basic.py
+++ b/examples/basic.py
@@ -9,7 +9,7 @@
6) Shell-like capabilities
"""
import cmd2
-from cmd2 import style
+from cmd2 import style, fg, bg
class BasicApp(cmd2.Cmd):
@@ -19,7 +19,7 @@ class BasicApp(cmd2.Cmd):
super().__init__(multiline_commands=['echo'], persistent_history_file='cmd2_history.dat',
startup_script='scripts/startup.txt', use_ipython=True)
- self.intro = style('Welcome to PyOhio 2019 and cmd2!', fg='red', bg='white', bold=True) + ' 😀'
+ self.intro = style('Welcome to PyOhio 2019 and cmd2!', fg=fg.red, bg=bg.white, bold=True) + ' 😀'
# Allow access to your application in py and ipy via self
self.self_in_py = True
diff --git a/examples/colors.py b/examples/colors.py
index 33b17e53..1466471b 100755
--- a/examples/colors.py
+++ b/examples/colors.py
@@ -48,8 +48,8 @@ class CmdLineApp(cmd2.Cmd):
speak_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
speak_parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE')
speak_parser.add_argument('-r', '--repeat', type=int, help='output [n] times')
- speak_parser.add_argument('-f', '--fg', choices=ansi.FG_COLORS, help='foreground color to apply to output')
- speak_parser.add_argument('-b', '--bg', choices=ansi.BG_COLORS, help='background color to apply to output')
+ speak_parser.add_argument('-f', '--fg', choices=ansi.fg.colors(), help='foreground color to apply to output')
+ speak_parser.add_argument('-b', '--bg', choices=ansi.bg.colors(), help='background color to apply to output')
speak_parser.add_argument('-l', '--bold', action='store_true', help='bold the output')
speak_parser.add_argument('-u', '--underline', action='store_true', help='underline the output')
speak_parser.add_argument('words', nargs='+', help='words to say')
diff --git a/examples/initialization.py b/examples/initialization.py
index c13ed137..609255f1 100755
--- a/examples/initialization.py
+++ b/examples/initialization.py
@@ -13,8 +13,7 @@
10) How to make custom attributes settable at runtime
"""
import cmd2
-from cmd2 import style
-from cmd2.ansi import FG_COLORS
+from cmd2 import style, fg, bg
class BasicApp(cmd2.Cmd):
@@ -25,7 +24,7 @@ class BasicApp(cmd2.Cmd):
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)
+ 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> '
@@ -44,7 +43,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))
+ choices=fg.colors()))
@cmd2.with_category(CUSTOM_CATEGORY)
def do_intro(self, _):
diff --git a/examples/pirate.py b/examples/pirate.py
index acbab17c..a50f9a51 100755
--- a/examples/pirate.py
+++ b/examples/pirate.py
@@ -25,7 +25,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``', choices=cmd2.ansi.fg.colors()))
# prompts and defaults
self.gold = 0