Skip to content

Commit 970ff2d

Browse files
committed
Updated documentation.
1 parent 02327aa commit 970ff2d

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ prompt is displayed.
7272
- Renamed `cmd2_handler` to `cmd2_subcmd_handler` in the `argparse.Namespace` for clarity.
7373
- Removed `Cmd2AttributeWrapper` class. `argparse.Namespace` objects passed to command functions
7474
now contain direct attributes for `cmd2_statement` and `cmd2_subcmd_handler`.
75+
- Removed `Cmd.doc_header` and the `with_default_category` decorator. Help categorization is now
76+
driven by the `DEFAULT_CATEGORY` class variable (see **Simplified command categorization** in
77+
the Enhancements section below for details).
7578
- Enhancements
7679
- New `cmd2.Cmd` parameters
7780
- **auto_suggest**: (boolean) if `True`, provide fish shell style auto-suggestions. These
@@ -97,6 +100,11 @@ prompt is displayed.
97100
- Add support for Python 3.15 by fixing various bugs related to internal `argparse` changes
98101
- Added `common_prefix` method to `cmd2.string_utils` module as a replacement for
99102
`os.path.commonprefix` since that is now deprecated in Python 3.15
103+
- Simplified command categorization:
104+
- By default, all commands in a class are grouped under its `DEFAULT_CATEGORY`.
105+
- Individual commands can still be manually moved using the `with_category()` decorator.
106+
- For more details and examples, see the [Help](docs/features/help.md) documentation and the
107+
`examples/default_categories.py` file.
100108

101109
## 3.4.0 (March 3, 2026)
102110

docs/features/help.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ category, and the display is driven by the `DEFAULT_CATEGORY` class variable.
5656
There are 3 methods of specifying command categories:
5757

5858
1. Using the `DEFAULT_CATEGORY` class variable (Automatic)
59-
1. Using the [@with_category][cmd2.with_category] decorator (Surgical)
59+
1. Using the [@with_category][cmd2.with_category] decorator (Manual)
6060
1. Using the [categorize()][cmd2.categorize] function (Manual)
6161

6262
### Automatic Categorization

docs/features/initialization.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ Certain things must be initialized within the `__init__()` method of your class
1616

1717
::: cmd2.Cmd.__init__
1818

19+
## Cmd class variables
20+
21+
The `cmd2.Cmd` class provides several class-level variables that can be overridden in subclasses to change default behavior across all instances of that class.
22+
23+
- **DEFAULT_CATEGORY**: The default help category for documented commands defined in the class that haven't been explicitly categorized. (Default: `"Cmd2 Commands"`)
24+
- **DEFAULT_EDITOR**: The default editor program used by the `edit` command.
25+
- **DEFAULT_PROMPT**: The default prompt string. (Default: `"(Cmd) "`)
26+
- **MISC_HEADER**: Header for the help section listing miscellaneous help topics. (Default: `"Miscellaneous Help Topics"`)
27+
- **UNDOC_HEADER**: Header for the help section listing undocumented commands. (Default: `"Undocumented Commands"`)
28+
1929
## Cmd instance attributes
2030

2131
The `cmd2.Cmd` class provides a large number of public instance attributes which allow developers to customize a `cmd2` application further beyond the options provided by the `__init__()` method.

0 commit comments

Comments
 (0)