Skip to content

Commit cf9b7c5

Browse files
committed
Address PR comments
1 parent 3caf4fc commit cf9b7c5

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 4.0.0 (TBD)
2+
3+
- Breaking Changes
4+
- `cmd2` no longer has a dependency on `cmd` and `cmd2.Cmd` no longer inherits from `cmd.Cmd`
5+
16
## 3.0.0 (December 7, 2025)
27

38
### Summary

cmd2/cmd2.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
"""Variant on standard library's cmd with extra features.
2-
3-
To use, simply import cmd2.Cmd instead of cmd.Cmd; use precisely as though you
4-
were using the standard library's cmd, while enjoying the extra features.
5-
6-
Searchable command history (commands: "history")
7-
Run commands from file, save to file, edit commands in file
8-
Multi-line commands
9-
Special-character shortcut commands (beyond cmd's "?" and "!")
10-
Settable environment parameters
11-
Parsing commands with `argparse` argument parsers (flags)
12-
Redirection to file or paste buffer (clipboard) with > or >>
13-
Easy transcript-based testing of applications (see examples/transcript_example.py)
14-
Bash-style ``select`` available
1+
"""cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python.
2+
3+
cmd2 is a tool for building interactive command line applications in Python. Its goal is to make it quick and easy for
4+
developers to build feature-rich and user-friendly interactive command line applications. It provides a simple API which
5+
is an extension of Python's built-in cmd module. cmd2 provides a wealth of features on top of cmd to make your life easier
6+
and eliminates much of the boilerplate code which would be necessary when using cmd.
7+
8+
Extra features include:
9+
- Searchable command history (commands: "history")
10+
- Run commands from file, save to file, edit commands in file
11+
- Multi-line commands
12+
- Special-character shortcut commands (beyond cmd's "?" and "!")
13+
- Settable environment parameters
14+
- Parsing commands with `argparse` argument parsers (flags)
15+
- Redirection to file or paste buffer (clipboard) with > or >>
16+
- Easy transcript-based testing of applications (see examples/transcript_example.py)
17+
- Bash-style ``select`` available
1518
1619
Note, if self.stdout is different than sys.stdout, then redirection with > and |
1720
will only work if `self.poutput()` is used in place of `print`.
1821
19-
- Catherine Devlin, Jan 03 2008 - catherinedevlin.blogspot.com
20-
21-
Git repository on GitHub at https://github.com/python-cmd2/cmd2
22+
GitHub: https://github.com/python-cmd2/cmd2
23+
Documentation: https://cmd2.readthedocs.io/
2224
"""
2325

2426
# This module has many imports, quite a few of which are only
@@ -63,7 +65,7 @@
6365
)
6466

6567
import rich.box
66-
from rich.console import Group
68+
from rich.console import Group, RenderableType
6769
from rich.highlighter import ReprHighlighter
6870
from rich.rule import Rule
6971
from rich.style import Style, StyleType
@@ -304,7 +306,6 @@ class Cmd:
304306
testfiles: ClassVar[list[str]] = []
305307

306308
DEFAULT_PROMPT = '(Cmd) '
307-
IDENTCHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'
308309

309310
def __init__(
310311
self,
@@ -328,7 +329,7 @@ def __init__(
328329
auto_load_commands: bool = False,
329330
allow_clipboard: bool = True,
330331
suggest_similar_command: bool = False,
331-
intro: str = '',
332+
intro: RenderableType = '',
332333
) -> None:
333334
"""Easy but powerful framework for writing line-oriented command interpreters, extends Python's cmd package.
334335
@@ -393,7 +394,6 @@ def __init__(
393394

394395
# Configure a few defaults
395396
self.prompt = Cmd.DEFAULT_PROMPT
396-
self.identchars = Cmd.IDENTCHARS
397397
self.intro = intro
398398
self.use_rawinput = True
399399

@@ -2715,10 +2715,6 @@ def postloop(self) -> None:
27152715
def parseline(self, line: str) -> tuple[str, str, str]:
27162716
"""Parse the line into a command name and a string containing the arguments.
27172717
2718-
NOTE: This is an override of a parent class method. It is only used by other parent class methods.
2719-
2720-
Different from the parent class method, this ignores self.identchars.
2721-
27222718
:param line: line read by readline
27232719
:return: tuple containing (command, args, line)
27242720
"""

docs/migrating/why.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ top-notch interactive command-line experience for their users.
2424

2525
!!! warning
2626

27-
As of version 4.0.0, `cmd2` does not have an actual dependency on `cmd`. It is API compatible, but
28-
the `cmd2.Cmd` class no longer inherits from `cmd.Cmd`.
27+
As of version 4.0.0, `cmd2` does not have an actual dependency on `cmd`. `cmd2` is mostly API compatible with `cmd2`.
28+
See [Incompatibilities](./incompatibilities.md) for the few documented incompatibilities.
2929

3030
## Automatic Features
3131

0 commit comments

Comments
 (0)