cmd2 4.2.1__tar.gz → 4.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cmd2-4.2.1 → cmd2-4.2.2}/CHANGELOG.md +7 -2
- {cmd2-4.2.1 → cmd2-4.2.2}/PKG-INFO +1 -1
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2.egg-info/PKG-INFO +1 -1
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2.egg-info/SOURCES.txt +1 -0
- cmd2-4.2.2/cmd2.egg-info/scm_version.json +8 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/os.md +21 -33
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/startup_commands.md +19 -6
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/README.md +4 -2
- cmd2-4.2.2/examples/cmd2_history.dat +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/cmd_as_argument.py +13 -31
- cmd2-4.2.1/cmd2.egg-info/scm_version.json +0 -8
- {cmd2-4.2.1 → cmd2-4.2.2}/.pre-commit-config.yaml +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/.prettierignore +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/.prettierrc +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/.typos.toml +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/GEMINI.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/LICENSE +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/MANIFEST.in +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/Makefile +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/README.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/__init__.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/annotated.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/argparse_completer.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/argparse_utils.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/clipboard.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/cmd2.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/colors.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/command_set.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/completion.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/constants.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/decorators.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/exceptions.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/history.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/parsing.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/plugin.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/pt_utils.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/py.typed +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/py_bridge.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/rich_utils.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/string_utils.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/styles.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/theme.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/types.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2/utils.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2.egg-info/dependency_links.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2.egg-info/requires.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2.egg-info/scm_file_list.json +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2.egg-info/top_level.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/cmd2.png +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/codecov.yml +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/annotated.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/argparse_completer.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/argparse_utils.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/clipboard.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/cmd.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/colors.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/command_set.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/completion.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/constants.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/decorators.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/exceptions.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/history.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/index.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/parsing.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/plugin.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/pt_utils.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/py_bridge.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/rich_utils.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/string_utils.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/styles.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/theme.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/api/utils.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/doc_conventions.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/examples/alternate_event_loops.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/examples/examples.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/examples/getting_started.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/examples/index.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/annotated.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/argument_processing.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/async_commands.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/builtin_commands.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/clipboard.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/commands.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/completion.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/disable_commands.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/embedded_python_shells.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/generating_output.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/help.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/history.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/hooks.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/index.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/initialization.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/misc.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/modular_commands.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/multiline_commands.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/packaging.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/plugins.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/prompt.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/redirection.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/scripting.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/settings.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/shortcuts_aliases_macros.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/table_creation.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/features/theme.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/index.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/javascripts/readthedocs.js +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/migrating/incompatibilities.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/migrating/index.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/migrating/minimum.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/migrating/next_steps.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/migrating/why.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/mixins/index.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/mixins/mixin_template.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/overrides/main.html +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/overview/alternatives.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/overview/index.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/overview/installation.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/overview/integrating.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/overview/resources.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/stylesheets/cmd2.css +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/testing.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/docs/upgrades.md +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/.cmd2rc +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/annotated_example.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/argparse_completion.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/argparse_example.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/async_call.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/async_commands.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/async_printing.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/basic_completion.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/color.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/command_sets.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/completion_item_choices.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/custom_parser.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/custom_types.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/default_categories.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/dynamic_commands.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/environment.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/event_loops.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/exit_code.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/getting_started.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/hello_cmd2.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/help_categories.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/hooks.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/migrating.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/mixin.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/modular_commands/__init__.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/modular_commands/commandset_basic.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/modular_commands/commandset_complex.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/modular_commands/commandset_custominit.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/modular_commandsets.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/paged_output.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/persistent_history.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/pretty_print.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/python_scripting.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/read_input.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/remove_builtin_commands.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/remove_settable.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/rich_tables.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/rich_theme.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/scripts/arg_printer.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/scripts/conditional.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/scripts/nested.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/scripts/quit.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/scripts/save_help_text.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/scripts/script.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/scripts/script.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/tmux_launch.sh +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/tmux_split.sh +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/examples/unicode_commands.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/mkdocs.yml +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/package.json +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/pyproject.toml +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/ruff.toml +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/scripts/validate_tag.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/setup.cfg +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/.cmd2rc +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/__init__.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/conftest.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/pyscript/echo.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/pyscript/environment.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/pyscript/help.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/pyscript/py_locals.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/pyscript/pyscript_dir.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/pyscript/raises_exception.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/pyscript/recursive.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/pyscript/self_in_py.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/pyscript/stop.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/pyscript/test_print.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/relative_multiple.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/script.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/script.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/scripts/binary.bin +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/scripts/empty.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/scripts/help.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/scripts/nested.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/scripts/one_down.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/scripts/postcmds.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/scripts/precmds.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/scripts/utf8.txt +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_annotated.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_argparse.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_argparse_completer.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_argparse_subcommands.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_argparse_utils.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_categories.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_cmd2.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_commandset.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_completion.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_dynamic_complete_style.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_future_annotations.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_history.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_parsing.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_plugin.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_pt_utils.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_py_completion.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_rich_utils.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_run_pyscript.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_string_utils.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_theme.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_utils.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/tests/test_utils_defining_class.py +0 -0
- {cmd2-4.2.1 → cmd2-4.2.2}/ty.toml +0 -0
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
## 4.2.2 (August 25, 2026)
|
|
2
|
+
|
|
3
|
+
- Documentation Improvements
|
|
4
|
+
- Improved documentation in attempt at making some recommended best-practices more discoverable
|
|
5
|
+
- Fixed the broken `cmd_as_argument` example
|
|
6
|
+
|
|
1
7
|
## 4.2.1 (August 22, 2026)
|
|
2
8
|
|
|
3
9
|
- Enhancements
|
|
4
10
|
- Added bracketed paste support so multiple pasted commands execute sequentially and multiline
|
|
5
11
|
commands continue as expected.
|
|
6
|
-
|
|
7
12
|
- Bug Fixes
|
|
8
13
|
- Enabled Ctrl-Z suspension at the prompt
|
|
9
14
|
|
|
@@ -1895,7 +1900,7 @@ time reading the [rich documentation](https://rich.readthedocs.io/).
|
|
|
1895
1900
|
- **with_argument_list** decorator to change argument type from str to List[str]
|
|
1896
1901
|
- **do\_\*** commands get a single argument which is a list of strings, as pre-parsed by
|
|
1897
1902
|
shlex.split()
|
|
1898
|
-
- **
|
|
1903
|
+
- **with_argparser** decorator for strict argparse-based argument parsing of command
|
|
1899
1904
|
arguments
|
|
1900
1905
|
- **do\_\*** commands get a single argument which is the output of argparse.parse_args()
|
|
1901
1906
|
- **with_argparser_and_unknown_args** decorator for argparse-based argument parsing, but
|
|
@@ -75,25 +75,25 @@ Either of these methods will launch your program and enter the `cmd2` command lo
|
|
|
75
75
|
user to enter commands, which are then executed by your program.
|
|
76
76
|
|
|
77
77
|
You may want to execute commands in your program without prompting the user for any input. There are
|
|
78
|
-
several ways you might accomplish this task.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
several ways you might accomplish this task. One is to pipe commands and their arguments into your
|
|
79
|
+
program via standard input. You don't need to do anything to your program in order to use this
|
|
80
|
+
technique. Here's a demonstration using the `examples/cmd_as_argument.py` included in the source
|
|
81
|
+
code of `cmd2`:
|
|
82
82
|
|
|
83
|
-
$ echo "speak -p some words" |
|
|
83
|
+
$ echo "speak -p some words" | uv run examples/cmd_as_argument.py
|
|
84
84
|
omesay ordsway
|
|
85
85
|
|
|
86
86
|
Using this same approach you could create a text file containing the commands you would like to run,
|
|
87
87
|
one command per line in the file. Say your file was called `somecmds.txt`. To run the commands in
|
|
88
88
|
the text file using your `cmd2` program (from a Windows command prompt):
|
|
89
89
|
|
|
90
|
-
c:\cmd2> type somecmds.txt |
|
|
90
|
+
c:\cmd2> type somecmds.txt | uv run examples/cmd_as_argument.py
|
|
91
91
|
omesay ordsway
|
|
92
92
|
|
|
93
93
|
By default, `cmd2` programs also look for commands passed as arguments from the operating system
|
|
94
94
|
shell, and execute those commands before entering the command loop:
|
|
95
95
|
|
|
96
|
-
$
|
|
96
|
+
$ uv run examples/cmd_as_argument.py help
|
|
97
97
|
|
|
98
98
|
Documented Commands
|
|
99
99
|
───────────────────
|
|
@@ -105,35 +105,23 @@ shell, and execute those commands before entering the command loop:
|
|
|
105
105
|
You may need more control over command line arguments passed from the operating system shell. For
|
|
106
106
|
example, you might have a command inside your `cmd2` program which itself accepts arguments, and
|
|
107
107
|
maybe even option strings. Say you wanted to run the `speak` command from the operating system
|
|
108
|
-
shell, but have it say it in pig latin
|
|
109
|
-
|
|
110
|
-
$ python examples/cmd_as_argument.py speak -p hello there
|
|
111
|
-
python cmd_as_argument.py speak -p hello there
|
|
112
|
-
usage: speak [-h] [-p] [-s] [-r REPEAT] words [words ...]
|
|
113
|
-
speak: error: the following arguments are required: words
|
|
114
|
-
*** Unknown syntax: -p
|
|
115
|
-
*** Unknown syntax: hello
|
|
116
|
-
*** Unknown syntax: there
|
|
117
|
-
(Cmd)
|
|
118
|
-
|
|
119
|
-
Uh-oh, that's not what we wanted. `cmd2` treated `-p`, `hello`, and `there` as commands, which don't
|
|
120
|
-
exist in that program, thus the syntax errors.
|
|
121
|
-
|
|
122
|
-
There is an easy way around this, which is demonstrated in
|
|
123
|
-
[cmd_as_argument.py](https://github.com/python-cmd2/cmd2/blob/main/examples/cmd_as_argument.py)
|
|
124
|
-
example. By setting `allow_cli_args=False` you can do your own argument parsing of the command line:
|
|
108
|
+
shell, but have it say it in pig latin - just group the command and its arguments inside either
|
|
109
|
+
double or single quotes:
|
|
125
110
|
|
|
126
|
-
$
|
|
111
|
+
$ uv run examples/cmd_as_argument.py "speak -p hello there"
|
|
127
112
|
ellohay heretay
|
|
113
|
+
(Cmd)
|
|
128
114
|
|
|
129
|
-
|
|
115
|
+
If you want to start your application using a custom `argparse` parser to collect high-level
|
|
116
|
+
application arguments but still want to be able to pass extra unknown arguments as commands at
|
|
117
|
+
invocation, then see the
|
|
118
|
+
[argparse_example.py](https://github.com/python-cmd2/cmd2/blob/main/examples/argparse_example.py)
|
|
119
|
+
example. Using this methodology you can call it like so:
|
|
130
120
|
|
|
131
|
-
|
|
132
|
-
quotes):
|
|
121
|
+
$ uv run examples/argparse_example.py -c blue help
|
|
133
122
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
(Cmd)
|
|
123
|
+
Check the source code of this example, especially the `if __name__ == "__main__":` block, to see the
|
|
124
|
+
technique.
|
|
137
125
|
|
|
138
126
|
### Automating cmd2 apps from other CLI/CLU tools
|
|
139
127
|
|
|
@@ -150,13 +138,13 @@ This is easily achieved by combining the following capabilities of `cmd2`:
|
|
|
150
138
|
Here is a simple example which doesn't require the quit command since the custom `exit` command
|
|
151
139
|
quits while returning an exit code:
|
|
152
140
|
|
|
153
|
-
$
|
|
141
|
+
$ uv run examples/exit_code.py "exit 23"
|
|
154
142
|
'examples/exit_code.py' exiting with code: 23
|
|
155
143
|
$ echo $?
|
|
156
144
|
23
|
|
157
145
|
|
|
158
146
|
Here is another example using `quit`:
|
|
159
147
|
|
|
160
|
-
$
|
|
148
|
+
$ uv run examples/cmd_as_argument.py "speak -p hello there" quit
|
|
161
149
|
ellohay heretay
|
|
162
150
|
$
|
|
@@ -11,12 +11,12 @@ initializing so they are guaranteed to run before any _Commands At Invocation_.
|
|
|
11
11
|
|
|
12
12
|
## Commands At Invocation
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
program. `cmd2` interprets each argument as a separate command, so you should
|
|
16
|
-
in quotation marks if it is more than a one-word command. You can use either
|
|
17
|
-
for this purpose.
|
|
14
|
+
By default, users can send commands to your app as you invoke it by including them as extra
|
|
15
|
+
arguments to the program. `cmd2` interprets each argument as a separate command, so you should
|
|
16
|
+
enclose each command in quotation marks if it is more than a one-word command. You can use either
|
|
17
|
+
single or double quotes for this purpose.
|
|
18
18
|
|
|
19
|
-
$
|
|
19
|
+
$ uv run examples/cmd_as_argument.py "say hello" "say Gracie" quit
|
|
20
20
|
hello
|
|
21
21
|
Gracie
|
|
22
22
|
|
|
@@ -26,7 +26,9 @@ application and easily used in automation.
|
|
|
26
26
|
|
|
27
27
|
!!! note
|
|
28
28
|
|
|
29
|
-
If you wish to disable cmd2's consumption of command-line arguments, you can do so by setting the `allow_cli_args` argument of your [cmd2.Cmd][] class instance to `False`.
|
|
29
|
+
If you wish to disable cmd2's consumption of command-line arguments, you can do so by setting the `allow_cli_args` argument of your [cmd2.Cmd][] class instance to `False`.
|
|
30
|
+
This would be useful, for example, if you wish to use something like [argparse](https://docs.python.org/3/library/argparse.html) to parse the overall command line arguments
|
|
31
|
+
for your application:
|
|
30
32
|
|
|
31
33
|
```py
|
|
32
34
|
from cmd2 import Cmd
|
|
@@ -35,6 +37,17 @@ application and easily used in automation.
|
|
|
35
37
|
super().__init__(allow_cli_args=False)
|
|
36
38
|
```
|
|
37
39
|
|
|
40
|
+
!!! tip
|
|
41
|
+
|
|
42
|
+
If you want to use something like [argparse](https://docs.python.org/3/library/argparse.html) to parse the overall command line arguments for your application
|
|
43
|
+
but still want to be able to pass any extra arguments to your application as commands, then see the `if __name__ == "__main__":` block at the end of the
|
|
44
|
+
[argparse_example.py](https://github.com/python-cmd2/cmd2/blob/main/examples/argparse_example.py) example.
|
|
45
|
+
|
|
46
|
+
This can be run like so:
|
|
47
|
+
```sh
|
|
48
|
+
uv run examples/argparse_example.py -c blue help quit
|
|
49
|
+
```
|
|
50
|
+
|
|
38
51
|
## Startup Script
|
|
39
52
|
|
|
40
53
|
You can execute commands from an initialization script by passing a file path to the
|
|
@@ -17,6 +17,8 @@ each:
|
|
|
17
17
|
- Comprehensive example demonstrating various aspects of using
|
|
18
18
|
[argparse](https://docs.python.org/3/library/argparse.html) for command argument processing
|
|
19
19
|
via the `cmd2.with_argparser` decorator
|
|
20
|
+
- Also demonstrates how to use a custom `argparse` parser when invoking your application and
|
|
21
|
+
still pass commands at invocation
|
|
20
22
|
- [async_call.py](https://github.com/python-cmd2/cmd2/blob/main/examples/async_call.py)
|
|
21
23
|
- Shows how to make a call to an async function from a cmd2 command.
|
|
22
24
|
- [async_commands.py](https://github.com/python-cmd2/cmd2/blob/main/examples/async_commands.py)
|
|
@@ -26,8 +28,8 @@ each:
|
|
|
26
28
|
title
|
|
27
29
|
- [basic_completion.py](https://github.com/python-cmd2/cmd2/blob/main/examples/basic_completion.py)
|
|
28
30
|
- Show how to enable custom tab completion by assigning a completer function to `do_*` commands
|
|
29
|
-
- [
|
|
30
|
-
- Demonstrates how to accept
|
|
31
|
+
- [cmd_as_argument.py](https://github.com/python-cmd2/cmd2/blob/main/examples/cmd_as_argument.py)
|
|
32
|
+
- Demonstrates how to accept command-line arguments when invoking a cmd2 application
|
|
31
33
|
- [color.py](https://github.com/python-cmd2/cmd2/blob/main/examples/color.py)
|
|
32
34
|
- Show the numerous colors available to use in your cmd2 applications
|
|
33
35
|
- [command_sets.py](https://github.com/python-cmd2/cmd2/blob/main/examples/command_sets.py)
|
|
Binary file
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
"""A sample application for cmd2.
|
|
3
3
|
|
|
4
|
-
This example
|
|
5
|
-
|
|
4
|
+
This example relies on the `allow_cli_args` init parameter being `True` by default which allows passing commands on the
|
|
5
|
+
command line to execute when the application is invoked.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This can be run like so:
|
|
8
|
+
$ python cmd_as_argument.py "speak -p hello there" help
|
|
9
|
+
|
|
10
|
+
By default, the application will enter the interactive shell mode after executing the commands passed in on the command line.
|
|
11
|
+
You can have it exit after executing by providing `quit` as the last command.
|
|
12
|
+
Commands and arguments can be grouped together by including in quotes.
|
|
8
13
|
"""
|
|
9
14
|
|
|
10
|
-
import argparse
|
|
11
15
|
import secrets
|
|
12
16
|
|
|
13
17
|
import cmd2
|
|
@@ -24,7 +28,7 @@ class CmdLineApp(cmd2.Cmd):
|
|
|
24
28
|
shortcuts = dict(cmd2.DEFAULT_SHORTCUTS)
|
|
25
29
|
shortcuts.update({"&": "speak"})
|
|
26
30
|
# Set include_ipy to True to enable the "ipy" command which runs an interactive IPython shell
|
|
27
|
-
super().__init__(allow_cli_args=
|
|
31
|
+
super().__init__(allow_cli_args=True, include_ipy=True, multiline_commands=["orate"], shortcuts=shortcuts)
|
|
28
32
|
|
|
29
33
|
self.self_in_py = True
|
|
30
34
|
self.maxrepeats = 3
|
|
@@ -45,8 +49,8 @@ class CmdLineApp(cmd2.Cmd):
|
|
|
45
49
|
"""Repeats what you tell me to."""
|
|
46
50
|
words = []
|
|
47
51
|
for w in args.words:
|
|
48
|
-
word = w.
|
|
49
|
-
if args.piglatin:
|
|
52
|
+
word = w.strip()
|
|
53
|
+
if args.piglatin and word:
|
|
50
54
|
word = f"{word[1:]}{word[0]}ay"
|
|
51
55
|
if args.shout:
|
|
52
56
|
word = word.upper()
|
|
@@ -80,30 +84,8 @@ class CmdLineApp(cmd2.Cmd):
|
|
|
80
84
|
self.poutput(" ".join(output))
|
|
81
85
|
|
|
82
86
|
|
|
83
|
-
def main(argv=None):
|
|
84
|
-
"""Run when invoked from the operating system shell."""
|
|
85
|
-
parser = cmd2.Cmd2ArgumentParser(description="Commands as arguments")
|
|
86
|
-
command_help = "optional command to run, if no command given, enter an interactive shell"
|
|
87
|
-
parser.add_argument("command", nargs="?", help=command_help)
|
|
88
|
-
arg_help = "optional arguments for command"
|
|
89
|
-
parser.add_argument("command_args", nargs=argparse.REMAINDER, help=arg_help)
|
|
90
|
-
|
|
91
|
-
args = parser.parse_args(argv)
|
|
92
|
-
|
|
93
|
-
c = CmdLineApp()
|
|
94
|
-
|
|
95
|
-
sys_exit_code = 0
|
|
96
|
-
if args.command:
|
|
97
|
-
# we have a command, run it and then exit
|
|
98
|
-
c.onecmd_plus_hooks("{} {}".format(args.command, " ".join(args.command_args)))
|
|
99
|
-
else:
|
|
100
|
-
# we have no command, drop into interactive mode
|
|
101
|
-
sys_exit_code = c.cmdloop()
|
|
102
|
-
|
|
103
|
-
return sys_exit_code
|
|
104
|
-
|
|
105
|
-
|
|
106
87
|
if __name__ == "__main__":
|
|
107
88
|
import sys
|
|
108
89
|
|
|
109
|
-
|
|
90
|
+
app = CmdLineApp()
|
|
91
|
+
sys.exit(app.cmdloop())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|