MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / __init__

Method __init__

cmd2/cmd2.py:355–684  ·  view source on GitHub ↗

Easy but powerful framework for writing line-oriented command interpreters, extends Python's cmd package. :param completekey: name of a completion key, default to 'tab'. (If None or an empty string, 'tab' is used) :param stdin: alternate input file object, if not specified, sys.stdi

(
        self,
        completekey: str | None = None,
        stdin: TextIO | None = None,
        stdout: TextIO | None = None,
        *,
        allow_cli_args: bool = True,
        allow_clipboard: bool = True,
        allow_redirection: bool = True,
        auto_load_commands: bool = False,
        auto_suggest: bool = True,
        bottom_toolbar: bool = False,
        command_sets: Iterable[CommandSet[Any]] | None = None,
        include_ipy: bool = False,
        include_py: bool = False,
        intro: RenderableType = "",
        multiline_commands: Iterable[str] | None = None,
        persistent_history_file: str = "",
        persistent_history_length: int = 1000,
        shortcuts: Mapping[str, str] | None = None,
        silence_startup_script: bool = False,
        startup_script: str = "",
        suggest_similar_command: bool = False,
        terminators: Iterable[str] | None = None,
    )

Source from the content-addressed store, hash-verified

353 MISC_HEADER: ClassVar[str] = "Miscellaneous Help Topics"
354
355 def __init__(
356 self,
357 completekey: str | None = None,
358 stdin: TextIO | None = None,
359 stdout: TextIO | None = None,
360 *,
361 allow_cli_args: bool = True,
362 allow_clipboard: bool = True,
363 allow_redirection: bool = True,
364 auto_load_commands: bool = False,
365 auto_suggest: bool = True,
366 bottom_toolbar: bool = False,
367 command_sets: Iterable[CommandSet[Any]] | None = None,
368 include_ipy: bool = False,
369 include_py: bool = False,
370 intro: RenderableType = "",
371 multiline_commands: Iterable[str] | None = None,
372 persistent_history_file: str = "",
373 persistent_history_length: int = 1000,
374 shortcuts: Mapping[str, str] | None = None,
375 silence_startup_script: bool = False,
376 startup_script: str = "",
377 suggest_similar_command: bool = False,
378 terminators: Iterable[str] | None = None,
379 ) -> None:
380 """Easy but powerful framework for writing line-oriented command interpreters, extends Python's cmd package.
381
382 :param completekey: name of a completion key, default to 'tab'. (If None or an empty string, 'tab' is used)
383 :param stdin: alternate input file object, if not specified, sys.stdin is used
384 :param stdout: alternate output file object, if not specified, sys.stdout is used
385 :param allow_cli_args: if ``True``, then [cmd2.Cmd.__init__][] will process command
386 line arguments as either commands to be run. This should be
387 set to ``False`` if your application parses its own command line
388 arguments.
389 :param allow_clipboard: If False, cmd2 will disable clipboard interactions
390 :param allow_redirection: If ``False``, prevent output redirection and piping to shell
391 commands. This parameter prevents redirection and piping, but
392 does not alter parsing behavior. A user can still type
393 redirection and piping tokens, and they will be parsed as such
394 but they won't do anything.
395 :param auto_load_commands: If True, cmd2 will check for all subclasses of `CommandSet`
396 that are currently loaded by Python and automatically
397 instantiate and register all commands. If False, CommandSets
398 must be manually installed with `register_command_set`.
399 :param auto_suggest: If True, cmd2 will provide fish shell style auto-suggestions
400 based on history. User can press right-arrow key to accept the
401 provided suggestion.
402 :param bottom_toolbar: if ``True``, then a bottom toolbar will be displayed.
403 :param command_sets: Provide CommandSet instances to load during cmd2 initialization.
404 This allows CommandSets with custom constructor parameters to be
405 loaded. This also allows the a set of CommandSets to be provided
406 when `auto_load_commands` is set to False
407 :param include_ipy: should the "ipy" command be included for an embedded IPython shell
408 :param include_py: should the "py" command be included for an embedded Python shell
409 :param intro: introduction to display at startup
410 :param multiline_commands: Iterable of commands allowed to accept multi-line input
411 :param persistent_history_file: file path to load a persistent cmd2 command history from
412 :param persistent_history_length: max number of history items to write

Callers 1

__init__Method · 0.45

Calls 14

build_settablesMethod · 0.95
_initialize_historyMethod · 0.95
_create_main_sessionMethod · 0.95
_register_subcommandsMethod · 0.95
register_command_setMethod · 0.95
_autoload_commandsMethod · 0.95
get_all_commandsMethod · 0.95
_ConsoleCacheClass · 0.85
StatementParserClass · 0.85
CommandParsersClass · 0.85
isattyMethod · 0.80

Tested by

no test coverage detected