Skip to content

Commit 28296ba

Browse files
committed
Documented default cmd2 styles.
1 parent 6f74dd5 commit 28296ba

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

cmd2/cmd2.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ class Cmd(cmd.Cmd):
292292
Line-oriented command interpreters are often useful for test harnesses, internal tools, and rapid prototypes.
293293
"""
294294

295-
ruler = "─"
296295
DEFAULT_EDITOR = utils.find_editor()
297296

298297
# Sorting keys for strings
@@ -475,7 +474,10 @@ def __init__(
475474
# The multiline command currently being typed which is used to tab complete multiline commands.
476475
self._multiline_in_progress = ''
477476

478-
# Set text which prints right before all of the help topics are listed.
477+
# Characters used to draw a horizontal rule. Should not be blank.
478+
self.ruler = "─"
479+
480+
# Set text which prints right before all of the help tables are listed.
479481
self.doc_leader = ""
480482

481483
# Set header for table listing documented commands.
@@ -4175,8 +4177,7 @@ def print_topics(self, header: str, cmds: list[str] | None, cmdlen: int, maxcol:
41754177

41764178
header_grid = Table.grid()
41774179
header_grid.add_row(header, style=Cmd2Style.HELP_HEADER)
4178-
if self.ruler:
4179-
header_grid.add_row(Rule(characters=self.ruler))
4180+
header_grid.add_row(Rule(characters=self.ruler))
41804181
self.poutput(header_grid)
41814182
self.columnize(cmds, maxcol - 1)
41824183
self.poutput()

cmd2/styles.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class Cmd2Style(StrEnum):
3030
added here must have a corresponding style definition there.
3131
"""
3232

33-
ERROR = "cmd2.error"
34-
EXAMPLE = "cmd2.example"
35-
HELP_HEADER = "cmd2.help.header"
36-
HELP_LEADER = "cmd2.help.leader"
37-
RULE_LINE = "cmd2.rule.line"
38-
SUCCESS = "cmd2.success"
39-
WARNING = "cmd2.warning"
33+
ERROR = "cmd2.error" # Error text (used by perror())
34+
EXAMPLE = "cmd2.example" # Command line examples in help text
35+
HELP_HEADER = "cmd2.help.header" # Help table header text
36+
HELP_LEADER = "cmd2.help.leader" # Text right before the help tables are listed
37+
RULE_LINE = "rule.line" # Rich style for horizontal rules
38+
SUCCESS = "cmd2.success" # Success text (used by psuccess())
39+
WARNING = "cmd2.warning" # Warning text (used by pwarning())
4040

4141

4242
# Default styles used by cmd2. Tightly coupled with the Cmd2Style enum.

0 commit comments

Comments
 (0)