Skip to content

Commit 9420bb3

Browse files
committed
Updated color examples to support bold and underline options
1 parent 6232792 commit 9420bb3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

examples/colors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def __init__(self):
4848
speak_parser.add_argument('-r', '--repeat', type=int, help='output [n] times')
4949
speak_parser.add_argument('-f', '--fg', choices=ansi.FG_COLORS, help='foreground color to apply to output')
5050
speak_parser.add_argument('-b', '--bg', choices=ansi.BG_COLORS, help='background color to apply to output')
51+
speak_parser.add_argument('-l', '--bold', action='store_true', help='bold the output')
52+
speak_parser.add_argument('-u', '--underline', action='store_true', help='underline the output')
5153
speak_parser.add_argument('words', nargs='+', help='words to say')
5254

5355
@cmd2.with_argparser(speak_parser)
@@ -62,7 +64,7 @@ def do_speak(self, args):
6264
words.append(word)
6365

6466
repetitions = args.repeat or 1
65-
output_str = ansi.style(' '.join(words), fg=args.fg, bg=args.bg)
67+
output_str = ansi.style(' '.join(words), fg=args.fg, bg=args.bg, bold=args.bold, underline=args.underline)
6668

6769
for i in range(min(repetitions, self.maxrepeats)):
6870
# .poutput handles newlines, and accommodates output redirection too

examples/plumbum_colors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def __init__(self):
8686
speak_parser.add_argument('-r', '--repeat', type=int, help='output [n] times')
8787
speak_parser.add_argument('-f', '--fg', choices=FG_COLORS, help='foreground color to apply to output')
8888
speak_parser.add_argument('-b', '--bg', choices=BG_COLORS, help='background color to apply to output')
89+
speak_parser.add_argument('-l', '--bold', action='store_true', help='bold the output')
90+
speak_parser.add_argument('-u', '--underline', action='store_true', help='underline the output')
8991
speak_parser.add_argument('words', nargs='+', help='words to say')
9092

9193
@cmd2.with_argparser(speak_parser)
@@ -100,7 +102,7 @@ def do_speak(self, args):
100102
words.append(word)
101103

102104
repetitions = args.repeat or 1
103-
output_str = ansi.style(' '.join(words), fg=args.fg, bg=args.bg)
105+
output_str = ansi.style(' '.join(words), fg=args.fg, bg=args.bg, bold=args.bold, underline=args.underline)
104106

105107
for i in range(min(repetitions, self.maxrepeats)):
106108
# .poutput handles newlines, and accommodates output redirection too

0 commit comments

Comments
 (0)