cmd2 3.3.0__tar.gz → 3.4.0__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-3.3.0 → cmd2-3.4.0}/CHANGELOG.md +13 -1
- {cmd2-3.3.0 → cmd2-3.4.0}/PKG-INFO +1 -1
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/argparse_custom.py +2 -2
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/cmd2.py +43 -102
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/rich_utils.py +141 -3
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2.egg-info/PKG-INFO +1 -1
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_cmd2.py +0 -16
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_rich_utils.py +50 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/.pre-commit-config.yaml +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/.prettierignore +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/.prettierrc +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/GEMINI.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/LICENSE +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/MANIFEST.in +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/Makefile +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/README.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/__init__.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/argparse_completer.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/clipboard.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/colors.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/command_definition.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/constants.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/decorators.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/exceptions.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/history.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/parsing.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/plugin.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/py.typed +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/py_bridge.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/rl_utils.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/string_utils.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/styles.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/terminal_utils.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/transcript.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2/utils.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2.egg-info/SOURCES.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2.egg-info/dependency_links.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2.egg-info/requires.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2.egg-info/top_level.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/cmd2.png +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/codecov.yml +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/argparse_completer.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/argparse_custom.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/clipboard.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/cmd.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/colors.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/command_definition.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/constants.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/decorators.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/exceptions.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/history.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/index.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/parsing.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/plugin.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/py_bridge.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/rich_utils.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/rl_utils.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/string_utils.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/styles.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/terminal_utils.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/transcript.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/api/utils.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/doc_conventions.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/examples/alternate_event_loops.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/examples/examples.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/examples/getting_started.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/examples/index.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/argument_processing.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/builtin_commands.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/clipboard.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/commands.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/completion.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/disable_commands.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/embedded_python_shells.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/generating_output.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/help.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/history.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/hooks.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/index.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/initialization.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/misc.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/modular_commands.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/multiline_commands.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/os.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/packaging.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/plugins.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/prompt.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/redirection.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/scripting.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/settings.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/shortcuts_aliases_macros.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/startup_commands.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/table_creation.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/theme.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/features/transcripts.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/index.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/javascripts/readthedocs.js +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/migrating/incompatibilities.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/migrating/index.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/migrating/minimum.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/migrating/next_steps.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/migrating/why.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/mixins/index.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/mixins/mixin_template.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/overrides/main.html +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/overview/alternatives.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/overview/index.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/overview/installation.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/overview/integrating.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/overview/resources.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/stylesheets/cmd2.css +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/testing.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/docs/upgrades.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/.cmd2rc +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/README.md +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/argparse_completion.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/argparse_example.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/async_call.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/async_printing.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/basic_completion.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/cmd2_history.dat +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/cmd_as_argument.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/color.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/command_sets.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/custom_parser.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/custom_types.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/default_categories.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/dynamic_commands.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/environment.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/event_loops.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/exit_code.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/getting_started.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/hello_cmd2.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/help_categories.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/hooks.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/migrating.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/mixin.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/modular_commands/__init__.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/modular_commands/commandset_basic.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/modular_commands/commandset_complex.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/modular_commands/commandset_custominit.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/modular_commands.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/paged_output.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/persistent_history.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/pretty_print.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/python_scripting.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/read_input.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/remove_builtin_commands.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/remove_settable.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/rich_tables.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/rich_theme.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/scripts/arg_printer.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/scripts/conditional.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/scripts/nested.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/scripts/quit.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/scripts/save_help_text.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/scripts/script.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/scripts/script.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/tmux_launch.sh +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/tmux_split.sh +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/transcript_example.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/transcripts/exampleSession.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/transcripts/pirate.transcript +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/transcripts/quit.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/transcripts/transcript_regex.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/examples/unicode_commands.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/mkdocs.yml +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/package.json +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/pyproject.toml +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/ruff.toml +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/scripts/validate_tag.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/setup.cfg +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/.cmd2rc +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/__init__.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/conftest.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/pyscript/echo.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/pyscript/environment.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/pyscript/help.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/pyscript/py_locals.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/pyscript/pyscript_dir.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/pyscript/raises_exception.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/pyscript/recursive.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/pyscript/self_in_py.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/pyscript/stdout_capture.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/pyscript/stop.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/relative_multiple.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/script.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/script.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/scripts/binary.bin +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/scripts/empty.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/scripts/help.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/scripts/nested.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/scripts/one_down.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/scripts/postcmds.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/scripts/precmds.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/scripts/utf8.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_argparse.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_argparse_completer.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_argparse_custom.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_argparse_subcommands.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_async_alert.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_categories.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_commandset.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_completion.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_future_annotations.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_history.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_parsing.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_plugin.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_run_pyscript.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_string_utils.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_terminal_utils.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_transcript.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_utils.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/test_utils_defining_class.py +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/bol_eol.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/characterclass.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/dotstar.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/extension_notation.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/failure.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/from_cmdloop.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/multiline_no_regex.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/multiline_regex.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/no_output.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/no_output_last.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/singleslash.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/slashes_escaped.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/slashslash.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/spaces.txt +0 -0
- {cmd2-3.3.0 → cmd2-3.4.0}/tests/transcripts/word_boundaries.txt +0 -0
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
## 3.4.0 (March 3, 2026)
|
|
2
|
+
|
|
3
|
+
- Enhancements
|
|
4
|
+
- Moved cmd2-specific printing logic from `Cmd.print_to()` into `Cmd2BaseConsole.print()` and
|
|
5
|
+
`Cmd2BaseConsole.log()`. This removes need to pass a console object to `Cmd.print_to()`.
|
|
6
|
+
- Addressed a bug in `rich.console.Console` where complex renderables (like `Table` and `Rule`)
|
|
7
|
+
may not receive formatting settings passed to `console.print()` and `console.log()`.
|
|
8
|
+
|
|
9
|
+
- Breaking Changes
|
|
10
|
+
- Renamed the `destination` parameter of `Cmd.print_to()` back to `file` since you can no longer
|
|
11
|
+
pass in a console.
|
|
12
|
+
|
|
13
|
+
## 3.3.0 (March 1, 2026)
|
|
2
14
|
|
|
3
15
|
- Enhancements
|
|
4
16
|
- Added ability to pass a console object to `Cmd.print_to()`. This provides support for things
|
|
@@ -1361,10 +1361,10 @@ class Cmd2ArgumentParser(argparse.ArgumentParser):
|
|
|
1361
1361
|
|
|
1362
1362
|
self.print_usage(sys.stderr)
|
|
1363
1363
|
|
|
1364
|
-
#
|
|
1364
|
+
# Use console to add style since it will respect ALLOW_STYLE's value
|
|
1365
1365
|
console = self._get_formatter().console
|
|
1366
1366
|
with console.capture() as capture:
|
|
1367
|
-
console.print(formatted_message, style=Cmd2Style.ERROR
|
|
1367
|
+
console.print(formatted_message, style=Cmd2Style.ERROR)
|
|
1368
1368
|
formatted_message = f"{capture.get()}"
|
|
1369
1369
|
|
|
1370
1370
|
self.exit(2, f'{formatted_message}\n')
|
|
@@ -66,7 +66,6 @@ from typing import (
|
|
|
66
66
|
|
|
67
67
|
import rich.box
|
|
68
68
|
from rich.console import (
|
|
69
|
-
Console,
|
|
70
69
|
Group,
|
|
71
70
|
RenderableType,
|
|
72
71
|
)
|
|
@@ -1252,66 +1251,30 @@ class Cmd:
|
|
|
1252
1251
|
|
|
1253
1252
|
def print_to(
|
|
1254
1253
|
self,
|
|
1255
|
-
|
|
1254
|
+
file: IO[str],
|
|
1256
1255
|
*objects: Any,
|
|
1257
1256
|
sep: str = " ",
|
|
1258
1257
|
end: str = "\n",
|
|
1259
1258
|
style: StyleType | None = None,
|
|
1260
|
-
soft_wrap: bool
|
|
1261
|
-
emoji: bool
|
|
1262
|
-
markup: bool
|
|
1263
|
-
highlight: bool
|
|
1259
|
+
soft_wrap: bool = True,
|
|
1260
|
+
emoji: bool = False,
|
|
1261
|
+
markup: bool = False,
|
|
1262
|
+
highlight: bool = False,
|
|
1264
1263
|
rich_print_kwargs: RichPrintKwargs | None = None,
|
|
1265
1264
|
**kwargs: Any, # noqa: ARG002
|
|
1266
1265
|
) -> None:
|
|
1267
|
-
"""Print objects to a given
|
|
1268
|
-
|
|
1269
|
-
If ``destination`` is a file-like object, it is wrapped in a ``Cmd2GeneralConsole``
|
|
1270
|
-
which is configured for general-purpose printing. By default, it enables soft wrap and
|
|
1271
|
-
disables Rich's automatic detection for markup, emoji, and highlighting. These defaults
|
|
1272
|
-
can be overridden by passing explicit keyword arguments.
|
|
1273
|
-
|
|
1274
|
-
If ``destination`` is a ``Cmd2BaseConsole``, the console's default settings for
|
|
1275
|
-
soft wrap, markup, emoji, and highlighting are used unless overridden by passing
|
|
1276
|
-
explicit keyword arguments.
|
|
1277
|
-
|
|
1278
|
-
See the Rich documentation for more details on emoji codes, markup tags, and highlighting.
|
|
1279
|
-
|
|
1280
|
-
**Why use this method instead of console.print()?**
|
|
1281
|
-
|
|
1282
|
-
This method calls ``cmd2.rich_utils.prepare_objects_for_rendering()`` on the objects
|
|
1283
|
-
being printed. This ensures that strings containing ANSI style sequences are converted
|
|
1284
|
-
to Rich Text objects, so that Rich can correctly calculate their display width when
|
|
1285
|
-
printing.
|
|
1286
|
-
|
|
1287
|
-
Example:
|
|
1288
|
-
```py
|
|
1289
|
-
with console.capture() as capture:
|
|
1290
|
-
self.print_to(console, some_ansi_styled_string)
|
|
1291
|
-
```
|
|
1292
|
-
|
|
1293
|
-
!!! note
|
|
1294
|
-
|
|
1295
|
-
To ensure consistent behavior, this method requires a file-like object or
|
|
1296
|
-
an instance of ``Cmd2BaseConsole``.
|
|
1297
|
-
Consoles not derived from ``Cmd2BaseConsole`` are disallowed because:
|
|
1266
|
+
"""Print objects to a given file stream.
|
|
1298
1267
|
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
``Cmd2BaseConsole`` instead raises a catchable ``BrokenPipeError``,
|
|
1303
|
-
ensuring the CLI application remains alive if a pipe is closed.
|
|
1268
|
+
This method is configured for general-purpose printing. By default, it enables
|
|
1269
|
+
soft wrap and disables Rich's automatic detection for markup, emoji, and highlighting.
|
|
1270
|
+
These defaults can be overridden by passing explicit keyword arguments.
|
|
1304
1271
|
|
|
1305
|
-
:param
|
|
1306
|
-
wrapped in a ``Cmd2GeneralConsole`` to ensure they respect
|
|
1307
|
-
cmd2 global settings; otherwise, this must be an
|
|
1308
|
-
instance of ``Cmd2BaseConsole``.
|
|
1272
|
+
:param file: file stream being written to
|
|
1309
1273
|
:param objects: objects to print
|
|
1310
1274
|
:param sep: string to write between printed text. Defaults to " ".
|
|
1311
1275
|
:param end: string to write at end of printed text. Defaults to a newline.
|
|
1312
1276
|
:param style: optional style to apply to output
|
|
1313
|
-
:param soft_wrap: Enable soft wrap mode. Defaults to
|
|
1314
|
-
If None, the destination console's default behavior is used.
|
|
1277
|
+
:param soft_wrap: Enable soft wrap mode. Defaults to True.
|
|
1315
1278
|
If True, text that doesn't fit will run on to the following line,
|
|
1316
1279
|
just like with print(). This is useful for raw text and logs.
|
|
1317
1280
|
If False, Rich wraps text to fit the terminal width.
|
|
@@ -1320,44 +1283,23 @@ class Cmd:
|
|
|
1320
1283
|
For example, when soft_wrap is True Panels truncate text
|
|
1321
1284
|
which is wider than the terminal.
|
|
1322
1285
|
:param emoji: If True, Rich will replace emoji codes (e.g., :smiley:) with their
|
|
1323
|
-
corresponding Unicode characters. Defaults to
|
|
1324
|
-
If None, the destination console's default behavior is used.
|
|
1286
|
+
corresponding Unicode characters. Defaults to False.
|
|
1325
1287
|
:param markup: If True, Rich will interpret strings with tags (e.g., [bold]hello[/bold])
|
|
1326
|
-
as styled output. Defaults to
|
|
1327
|
-
If None, the destination console's default behavior is used.
|
|
1288
|
+
as styled output. Defaults to False.
|
|
1328
1289
|
:param highlight: If True, Rich will automatically apply highlighting to elements within
|
|
1329
1290
|
strings, such as common Python data types like numbers, booleans, or None.
|
|
1330
1291
|
This is particularly useful when pretty printing objects like lists and
|
|
1331
|
-
dictionaries to display them in color. Defaults to
|
|
1332
|
-
If None, the destination console's default behavior is used.
|
|
1292
|
+
dictionaries to display them in color. Defaults to False.
|
|
1333
1293
|
:param rich_print_kwargs: optional additional keyword arguments to pass to Rich's Console.print().
|
|
1334
1294
|
:param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this
|
|
1335
1295
|
method and still call `super()` without encountering unexpected keyword argument errors.
|
|
1336
1296
|
These arguments are not passed to Rich's Console.print().
|
|
1337
|
-
:raises TypeError: If ``destination`` is a non-cmd2 ``Console`` instance that
|
|
1338
|
-
does not derive from ``Cmd2BaseConsole``.
|
|
1339
1297
|
|
|
1298
|
+
See the Rich documentation for more details on emoji codes, markup tags, and highlighting.
|
|
1340
1299
|
"""
|
|
1341
|
-
if isinstance(destination, Console):
|
|
1342
|
-
if not isinstance(destination, Cmd2BaseConsole):
|
|
1343
|
-
# Explicitly reject non-cmd2 consoles to ensure safe behavior
|
|
1344
|
-
raise TypeError(
|
|
1345
|
-
f"destination must be a 'Cmd2BaseConsole' or a file-like object, "
|
|
1346
|
-
f"not a non-cmd2 '{type(destination).__name__}'. "
|
|
1347
|
-
"Consoles not derived from 'Cmd2BaseConsole' bypass cmd2's "
|
|
1348
|
-
"'ALLOW_STYLE' logic, 'APP_THEME' settings, and trigger 'SystemExit' "
|
|
1349
|
-
"on broken pipes."
|
|
1350
|
-
)
|
|
1351
|
-
console = destination
|
|
1352
|
-
else:
|
|
1353
|
-
# It's a file-like object (e.g., sys.stdout, StringIO)
|
|
1354
|
-
console = Cmd2GeneralConsole(file=destination)
|
|
1355
|
-
|
|
1356
|
-
prepared_objects = ru.prepare_objects_for_rendering(*objects)
|
|
1357
|
-
|
|
1358
1300
|
try:
|
|
1359
|
-
|
|
1360
|
-
*
|
|
1301
|
+
Cmd2BaseConsole(file=file).print(
|
|
1302
|
+
*objects,
|
|
1361
1303
|
sep=sep,
|
|
1362
1304
|
end=end,
|
|
1363
1305
|
style=style,
|
|
@@ -1373,7 +1315,7 @@ class Cmd:
|
|
|
1373
1315
|
# writing. If you would like your application to print a
|
|
1374
1316
|
# warning message, then set the broken_pipe_warning attribute
|
|
1375
1317
|
# to the message you want printed.
|
|
1376
|
-
if self.broken_pipe_warning and
|
|
1318
|
+
if self.broken_pipe_warning and file != sys.stderr:
|
|
1377
1319
|
Cmd2GeneralConsole(file=sys.stderr).print(self.broken_pipe_warning)
|
|
1378
1320
|
|
|
1379
1321
|
def poutput(
|
|
@@ -1382,10 +1324,10 @@ class Cmd:
|
|
|
1382
1324
|
sep: str = " ",
|
|
1383
1325
|
end: str = "\n",
|
|
1384
1326
|
style: StyleType | None = None,
|
|
1385
|
-
soft_wrap: bool
|
|
1386
|
-
emoji: bool
|
|
1387
|
-
markup: bool
|
|
1388
|
-
highlight: bool
|
|
1327
|
+
soft_wrap: bool = True,
|
|
1328
|
+
emoji: bool = False,
|
|
1329
|
+
markup: bool = False,
|
|
1330
|
+
highlight: bool = False,
|
|
1389
1331
|
rich_print_kwargs: RichPrintKwargs | None = None,
|
|
1390
1332
|
**kwargs: Any, # noqa: ARG002
|
|
1391
1333
|
) -> None:
|
|
@@ -1412,10 +1354,10 @@ class Cmd:
|
|
|
1412
1354
|
sep: str = " ",
|
|
1413
1355
|
end: str = "\n",
|
|
1414
1356
|
style: StyleType | None = Cmd2Style.ERROR,
|
|
1415
|
-
soft_wrap: bool
|
|
1416
|
-
emoji: bool
|
|
1417
|
-
markup: bool
|
|
1418
|
-
highlight: bool
|
|
1357
|
+
soft_wrap: bool = True,
|
|
1358
|
+
emoji: bool = False,
|
|
1359
|
+
markup: bool = False,
|
|
1360
|
+
highlight: bool = False,
|
|
1419
1361
|
rich_print_kwargs: RichPrintKwargs | None = None,
|
|
1420
1362
|
**kwargs: Any, # noqa: ARG002
|
|
1421
1363
|
) -> None:
|
|
@@ -1443,10 +1385,10 @@ class Cmd:
|
|
|
1443
1385
|
*objects: Any,
|
|
1444
1386
|
sep: str = " ",
|
|
1445
1387
|
end: str = "\n",
|
|
1446
|
-
soft_wrap: bool
|
|
1447
|
-
emoji: bool
|
|
1448
|
-
markup: bool
|
|
1449
|
-
highlight: bool
|
|
1388
|
+
soft_wrap: bool = True,
|
|
1389
|
+
emoji: bool = False,
|
|
1390
|
+
markup: bool = False,
|
|
1391
|
+
highlight: bool = False,
|
|
1450
1392
|
rich_print_kwargs: RichPrintKwargs | None = None,
|
|
1451
1393
|
**kwargs: Any, # noqa: ARG002
|
|
1452
1394
|
) -> None:
|
|
@@ -1471,10 +1413,10 @@ class Cmd:
|
|
|
1471
1413
|
*objects: Any,
|
|
1472
1414
|
sep: str = " ",
|
|
1473
1415
|
end: str = "\n",
|
|
1474
|
-
soft_wrap: bool
|
|
1475
|
-
emoji: bool
|
|
1476
|
-
markup: bool
|
|
1477
|
-
highlight: bool
|
|
1416
|
+
soft_wrap: bool = True,
|
|
1417
|
+
emoji: bool = False,
|
|
1418
|
+
markup: bool = False,
|
|
1419
|
+
highlight: bool = False,
|
|
1478
1420
|
rich_print_kwargs: RichPrintKwargs | None = None,
|
|
1479
1421
|
**kwargs: Any, # noqa: ARG002
|
|
1480
1422
|
) -> None:
|
|
@@ -1554,10 +1496,10 @@ class Cmd:
|
|
|
1554
1496
|
sep: str = " ",
|
|
1555
1497
|
end: str = "\n",
|
|
1556
1498
|
style: StyleType | None = None,
|
|
1557
|
-
soft_wrap: bool
|
|
1558
|
-
emoji: bool
|
|
1559
|
-
markup: bool
|
|
1560
|
-
highlight: bool
|
|
1499
|
+
soft_wrap: bool = True,
|
|
1500
|
+
emoji: bool = False,
|
|
1501
|
+
markup: bool = False,
|
|
1502
|
+
highlight: bool = False,
|
|
1561
1503
|
rich_print_kwargs: RichPrintKwargs | None = None,
|
|
1562
1504
|
**kwargs: Any, # noqa: ARG002
|
|
1563
1505
|
) -> None:
|
|
@@ -1602,9 +1544,9 @@ class Cmd:
|
|
|
1602
1544
|
style: StyleType | None = None,
|
|
1603
1545
|
chop: bool = False,
|
|
1604
1546
|
soft_wrap: bool = True,
|
|
1605
|
-
emoji: bool
|
|
1606
|
-
markup: bool
|
|
1607
|
-
highlight: bool
|
|
1547
|
+
emoji: bool = False,
|
|
1548
|
+
markup: bool = False,
|
|
1549
|
+
highlight: bool = False,
|
|
1608
1550
|
rich_print_kwargs: RichPrintKwargs | None = None,
|
|
1609
1551
|
**kwargs: Any, # noqa: ARG002
|
|
1610
1552
|
) -> None:
|
|
@@ -1646,10 +1588,9 @@ class Cmd:
|
|
|
1646
1588
|
soft_wrap = True
|
|
1647
1589
|
|
|
1648
1590
|
# Generate the bytes to send to the pager
|
|
1649
|
-
console =
|
|
1591
|
+
console = Cmd2BaseConsole(file=self.stdout)
|
|
1650
1592
|
with console.capture() as capture:
|
|
1651
|
-
|
|
1652
|
-
console,
|
|
1593
|
+
console.print(
|
|
1653
1594
|
*objects,
|
|
1654
1595
|
sep=sep,
|
|
1655
1596
|
end=end,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Provides common utilities to support Rich in cmd2-based applications."""
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
|
+
import threading
|
|
4
5
|
from collections.abc import Mapping
|
|
5
6
|
from enum import Enum
|
|
6
7
|
from typing import (
|
|
@@ -173,12 +174,152 @@ class Cmd2BaseConsole(Console):
|
|
|
173
174
|
theme=APP_THEME,
|
|
174
175
|
**kwargs,
|
|
175
176
|
)
|
|
177
|
+
self._thread_local = threading.local()
|
|
176
178
|
|
|
177
179
|
def on_broken_pipe(self) -> None:
|
|
178
180
|
"""Override which raises BrokenPipeError instead of SystemExit."""
|
|
179
181
|
self.quiet = True
|
|
180
182
|
raise BrokenPipeError
|
|
181
183
|
|
|
184
|
+
def render_str(
|
|
185
|
+
self,
|
|
186
|
+
text: str,
|
|
187
|
+
highlight: bool | None = None,
|
|
188
|
+
markup: bool | None = None,
|
|
189
|
+
emoji: bool | None = None,
|
|
190
|
+
**kwargs: Any,
|
|
191
|
+
) -> Text:
|
|
192
|
+
"""Override to ensure formatting overrides passed to print() and log() are respected."""
|
|
193
|
+
if emoji is None:
|
|
194
|
+
emoji = getattr(self._thread_local, "emoji", None)
|
|
195
|
+
if markup is None:
|
|
196
|
+
markup = getattr(self._thread_local, "markup", None)
|
|
197
|
+
if highlight is None:
|
|
198
|
+
highlight = getattr(self._thread_local, "highlight", None)
|
|
199
|
+
|
|
200
|
+
return super().render_str(text, highlight=highlight, markup=markup, emoji=emoji, **kwargs)
|
|
201
|
+
|
|
202
|
+
def print(
|
|
203
|
+
self,
|
|
204
|
+
*objects: Any,
|
|
205
|
+
sep: str = " ",
|
|
206
|
+
end: str = "\n",
|
|
207
|
+
style: StyleType | None = None,
|
|
208
|
+
justify: JustifyMethod | None = None,
|
|
209
|
+
overflow: OverflowMethod | None = None,
|
|
210
|
+
no_wrap: bool | None = None,
|
|
211
|
+
emoji: bool | None = None,
|
|
212
|
+
markup: bool | None = None,
|
|
213
|
+
highlight: bool | None = None,
|
|
214
|
+
width: int | None = None,
|
|
215
|
+
height: int | None = None,
|
|
216
|
+
crop: bool = True,
|
|
217
|
+
soft_wrap: bool | None = None,
|
|
218
|
+
new_line_start: bool = False,
|
|
219
|
+
) -> None:
|
|
220
|
+
"""Override to support ANSI sequences and address a bug in Rich.
|
|
221
|
+
|
|
222
|
+
This method calls [cmd2.rich_utils.prepare_objects_for_rendering][] on the
|
|
223
|
+
objects being printed. This ensures that strings containing ANSI style
|
|
224
|
+
sequences are converted to Rich Text objects, so that Rich can correctly
|
|
225
|
+
calculate their display width.
|
|
226
|
+
|
|
227
|
+
Additionally, it works around a bug in Rich where complex renderables
|
|
228
|
+
(like Table and Rule) may not receive formatting settings passed to print().
|
|
229
|
+
By temporarily injecting these settings into thread-local storage, we ensure
|
|
230
|
+
that all internal rendering calls within the print() operation respect the
|
|
231
|
+
requested overrides.
|
|
232
|
+
|
|
233
|
+
There is an issue on Rich to fix the latter:
|
|
234
|
+
https://github.com/Textualize/rich/issues/4028
|
|
235
|
+
"""
|
|
236
|
+
prepared_objects = prepare_objects_for_rendering(*objects)
|
|
237
|
+
|
|
238
|
+
# Inject overrides into thread-local storage
|
|
239
|
+
self._thread_local.emoji = emoji
|
|
240
|
+
self._thread_local.markup = markup
|
|
241
|
+
self._thread_local.highlight = highlight
|
|
242
|
+
|
|
243
|
+
try:
|
|
244
|
+
super().print(
|
|
245
|
+
*prepared_objects,
|
|
246
|
+
sep=sep,
|
|
247
|
+
end=end,
|
|
248
|
+
style=style,
|
|
249
|
+
justify=justify,
|
|
250
|
+
overflow=overflow,
|
|
251
|
+
no_wrap=no_wrap,
|
|
252
|
+
emoji=emoji,
|
|
253
|
+
markup=markup,
|
|
254
|
+
highlight=highlight,
|
|
255
|
+
width=width,
|
|
256
|
+
height=height,
|
|
257
|
+
crop=crop,
|
|
258
|
+
soft_wrap=soft_wrap,
|
|
259
|
+
new_line_start=new_line_start,
|
|
260
|
+
)
|
|
261
|
+
finally:
|
|
262
|
+
# Clear overrides from thread-local storage
|
|
263
|
+
self._thread_local.emoji = None
|
|
264
|
+
self._thread_local.markup = None
|
|
265
|
+
self._thread_local.highlight = None
|
|
266
|
+
|
|
267
|
+
def log(
|
|
268
|
+
self,
|
|
269
|
+
*objects: Any,
|
|
270
|
+
sep: str = " ",
|
|
271
|
+
end: str = "\n",
|
|
272
|
+
style: StyleType | None = None,
|
|
273
|
+
justify: JustifyMethod | None = None,
|
|
274
|
+
emoji: bool | None = None,
|
|
275
|
+
markup: bool | None = None,
|
|
276
|
+
highlight: bool | None = None,
|
|
277
|
+
log_locals: bool = False,
|
|
278
|
+
_stack_offset: int = 1,
|
|
279
|
+
) -> None:
|
|
280
|
+
"""Override to support ANSI sequences and address a bug in Rich.
|
|
281
|
+
|
|
282
|
+
This method calls [cmd2.rich_utils.prepare_objects_for_rendering][] on the
|
|
283
|
+
objects being logged. This ensures that strings containing ANSI style
|
|
284
|
+
sequences are converted to Rich Text objects, so that Rich can correctly
|
|
285
|
+
calculate their display width.
|
|
286
|
+
|
|
287
|
+
Additionally, it works around a bug in Rich where complex renderables
|
|
288
|
+
(like Table and Rule) may not receive formatting settings passed to log().
|
|
289
|
+
By temporarily injecting these settings into thread-local storage, we ensure
|
|
290
|
+
that all internal rendering calls within the log() operation respect the
|
|
291
|
+
requested overrides.
|
|
292
|
+
|
|
293
|
+
There is an issue on Rich to fix the latter:
|
|
294
|
+
https://github.com/Textualize/rich/issues/4028
|
|
295
|
+
"""
|
|
296
|
+
prepared_objects = prepare_objects_for_rendering(*objects)
|
|
297
|
+
|
|
298
|
+
# Inject overrides into thread-local storage
|
|
299
|
+
self._thread_local.emoji = emoji
|
|
300
|
+
self._thread_local.markup = markup
|
|
301
|
+
self._thread_local.highlight = highlight
|
|
302
|
+
|
|
303
|
+
try:
|
|
304
|
+
# Increment _stack_offset because we added this wrapper frame
|
|
305
|
+
super().log(
|
|
306
|
+
*prepared_objects,
|
|
307
|
+
sep=sep,
|
|
308
|
+
end=end,
|
|
309
|
+
style=style,
|
|
310
|
+
justify=justify,
|
|
311
|
+
emoji=emoji,
|
|
312
|
+
markup=markup,
|
|
313
|
+
highlight=highlight,
|
|
314
|
+
log_locals=log_locals,
|
|
315
|
+
_stack_offset=_stack_offset + 1,
|
|
316
|
+
)
|
|
317
|
+
finally:
|
|
318
|
+
# Clear overrides from thread-local storage
|
|
319
|
+
self._thread_local.emoji = None
|
|
320
|
+
self._thread_local.markup = None
|
|
321
|
+
self._thread_local.highlight = None
|
|
322
|
+
|
|
182
323
|
|
|
183
324
|
class Cmd2GeneralConsole(Cmd2BaseConsole):
|
|
184
325
|
"""Rich console for general-purpose printing.
|
|
@@ -273,9 +414,6 @@ def rich_text_to_string(text: Text) -> str:
|
|
|
273
414
|
force_terminal=True,
|
|
274
415
|
soft_wrap=True,
|
|
275
416
|
no_color=False,
|
|
276
|
-
markup=False,
|
|
277
|
-
emoji=False,
|
|
278
|
-
highlight=False,
|
|
279
417
|
theme=APP_THEME,
|
|
280
418
|
)
|
|
281
419
|
with console.capture() as capture:
|
|
@@ -2128,22 +2128,6 @@ def test_read_command_line_eof(base_app, monkeypatch) -> None:
|
|
|
2128
2128
|
assert line == 'eof'
|
|
2129
2129
|
|
|
2130
2130
|
|
|
2131
|
-
def test_print_to_custom_console(base_app) -> None:
|
|
2132
|
-
console = ru.Cmd2GeneralConsole()
|
|
2133
|
-
with console.capture() as capture:
|
|
2134
|
-
base_app.print_to(console, "hello")
|
|
2135
|
-
assert capture.get() == "hello\n"
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
def test_print_to_invalid_console_type(base_app) -> None:
|
|
2139
|
-
from rich.console import Console
|
|
2140
|
-
|
|
2141
|
-
console = Console()
|
|
2142
|
-
with pytest.raises(TypeError) as excinfo:
|
|
2143
|
-
base_app.print_to(console, "hello")
|
|
2144
|
-
assert "destination must be a 'Cmd2BaseConsole'" in str(excinfo.value)
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
2131
|
def test_poutput_string(outsim_app) -> None:
|
|
2148
2132
|
msg = 'This is a test'
|
|
2149
2133
|
outsim_app.poutput(msg)
|
|
@@ -13,6 +13,8 @@ from cmd2 import (
|
|
|
13
13
|
)
|
|
14
14
|
from cmd2 import rich_utils as ru
|
|
15
15
|
|
|
16
|
+
from .conftest import with_ansi_style
|
|
17
|
+
|
|
16
18
|
|
|
17
19
|
def test_cmd2_base_console() -> None:
|
|
18
20
|
# Test the keyword arguments which are not allowed.
|
|
@@ -142,3 +144,51 @@ def test_from_ansi_wrapper() -> None:
|
|
|
142
144
|
# Test empty string
|
|
143
145
|
input_string = ""
|
|
144
146
|
assert Text.from_ansi(input_string).plain == input_string
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@with_ansi_style(ru.AllowStyle.ALWAYS)
|
|
150
|
+
def test_cmd2_base_console_print() -> None:
|
|
151
|
+
"""Test that Cmd2BaseConsole.print() correctly propagates formatting overrides to structured renderables."""
|
|
152
|
+
from rich.rule import Rule
|
|
153
|
+
|
|
154
|
+
# Create a console that defaults to no formatting
|
|
155
|
+
console = ru.Cmd2BaseConsole(emoji=False, markup=False)
|
|
156
|
+
|
|
157
|
+
# Use a Rule with emoji and markup in the title
|
|
158
|
+
rule = Rule(title="[green]Success :1234:[/green]")
|
|
159
|
+
|
|
160
|
+
with console.capture() as capture:
|
|
161
|
+
# Override settings in the print() call
|
|
162
|
+
console.print(rule, emoji=True, markup=True)
|
|
163
|
+
|
|
164
|
+
result = capture.get()
|
|
165
|
+
|
|
166
|
+
# Verify that the overrides were respected by checking for the emoji and the color code
|
|
167
|
+
assert "🔢" in result
|
|
168
|
+
assert "\x1b[32mSuccess" in result
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@with_ansi_style(ru.AllowStyle.ALWAYS)
|
|
172
|
+
def test_cmd2_base_console_log() -> None:
|
|
173
|
+
"""Test that Cmd2BaseConsole.log() correctly propagates formatting overrides to structured renderables."""
|
|
174
|
+
from rich.rule import Rule
|
|
175
|
+
|
|
176
|
+
# Create a console that defaults to no formatting
|
|
177
|
+
console = ru.Cmd2BaseConsole(emoji=False, markup=False)
|
|
178
|
+
|
|
179
|
+
# Use a Rule with emoji and markup in the title
|
|
180
|
+
rule = Rule(title="[green]Success :1234:[/green]")
|
|
181
|
+
|
|
182
|
+
with console.capture() as capture:
|
|
183
|
+
# Override settings in the log() call
|
|
184
|
+
console.log(rule, emoji=True, markup=True)
|
|
185
|
+
|
|
186
|
+
result = capture.get()
|
|
187
|
+
|
|
188
|
+
# Verify that the formatting overrides were respected
|
|
189
|
+
assert "🔢" in result
|
|
190
|
+
assert "\x1b[32mSuccess" in result
|
|
191
|
+
|
|
192
|
+
# Verify stack offset: the log line should point to this file, not rich_utils.py
|
|
193
|
+
# Rich logs include the filename and line number on the right.
|
|
194
|
+
assert "test_rich_utils.py" in result
|
|
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
|