summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-06-28 01:11:27 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2019-06-28 01:11:27 -0400
commit9420bb387e8031a8d4a3078c6a17025780e27bf0 (patch)
treebf453a64bbd365e7e0a4723449845cf5b3b1e5c2
parent62327923a0f8db318dd6ff951b9d98a6b04bdbae (diff)
downloadcmd2-git-9420bb387e8031a8d4a3078c6a17025780e27bf0.tar.gz
Updated color examples to support bold and underline options
-rwxr-xr-xexamples/colors.py4
-rwxr-xr-xexamples/plumbum_colors.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/examples/colors.py b/examples/colors.py
index c0c221c8..8c54dfa4 100755
--- a/examples/colors.py
+++ b/examples/colors.py
@@ -48,6 +48,8 @@ class CmdLineApp(cmd2.Cmd):
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('-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')
@cmd2.with_argparser(speak_parser)
@@ -62,7 +64,7 @@ class CmdLineApp(cmd2.Cmd):
words.append(word)
repetitions = args.repeat or 1
- output_str = ansi.style(' '.join(words), fg=args.fg, bg=args.bg)
+ output_str = ansi.style(' '.join(words), fg=args.fg, bg=args.bg, bold=args.bold, underline=args.underline)
for i in range(min(repetitions, self.maxrepeats)):
# .poutput handles newlines, and accommodates output redirection too
diff --git a/examples/plumbum_colors.py b/examples/plumbum_colors.py
index 971029fa..a969c4de 100755
--- a/examples/plumbum_colors.py
+++ b/examples/plumbum_colors.py
@@ -86,6 +86,8 @@ class CmdLineApp(cmd2.Cmd):
speak_parser.add_argument('-r', '--repeat', type=int, help='output [n] times')
speak_parser.add_argument('-f', '--fg', choices=FG_COLORS, help='foreground color to apply to output')
speak_parser.add_argument('-b', '--bg', choices=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')
@cmd2.with_argparser(speak_parser)
@@ -100,7 +102,7 @@ class CmdLineApp(cmd2.Cmd):
words.append(word)
repetitions = args.repeat or 1
- output_str = ansi.style(' '.join(words), fg=args.fg, bg=args.bg)
+ output_str = ansi.style(' '.join(words), fg=args.fg, bg=args.bg, bold=args.bold, underline=args.underline)
for i in range(min(repetitions, self.maxrepeats)):
# .poutput handles newlines, and accommodates output redirection too