module documentation

Shared CLI objects, used by .ui and .formats.

Class Command Base class for all commands.
Class Subcommand Base class for all subcommands.
Class SubcommandOfNestedTextTo Base class for all subcommands of NestedTextTo.
Class SubcommandOfToNestedText Base class for all subcommands of ToNestedText.
Class SupportsDate Mixin for SubcommandOfNestedTextTo+SupportsTypes commands which support dates.
Class SupportsNull Mixin for SubcommandOfNestedTextTo+SupportsTypes commands which support null.
Class SupportsTypes Mixin for SubcommandOfNestedTextTo commands which support types.
Class ToNestedTextBase Base class for commands that convert to NestedText.
Function description_more_for_2nt_subcommand Add DESCRIPTION_MORE to a 2nt subcommand class.
Function description_more_for_subcommand Add DESCRIPTION_MORE to a subcommand class.
Function description_more_for_supports_types Add DESCRIPTION_MORE to an nt2 subcommand class.
Function docstring_for_subcommand Add a docstring to a subcommand class, using its DOCSTRING_TMPL and OTHER_FORMAT.
Function get_ntt_stdout Return the stdout content from the given command invocation.
Function invoke_ntt_command Invoke the command with the given arguments.
Function propagate_options_to_subcommand Add user-supplied opts from the root to its nested command, unless supplied there, too.
def description_more_for_2nt_subcommand(cls: type[SubcommandOfToNestedText]) -> type[SubcommandOfToNestedText]: (source)

Add DESCRIPTION_MORE to a 2nt subcommand class.

Makes use of its OTHER_FORMAT and DESCRIPTION_MORE_TMPL attributes.

Parameters
cls:type[SubcommandOfToNestedText]A SubcommandOfToNestedText class.
Returns
type[SubcommandOfToNestedText]The same cls, with DESCRIPTION_MORE added.
def description_more_for_subcommand(cls: type[SupportsTypes] | type[SubcommandOfToNestedText]) -> type[SupportsTypes] | type[SubcommandOfToNestedText]: (source)

Add DESCRIPTION_MORE to a subcommand class.

Dispatches to description_more_for_supports_types and description_more_for_2nt_subcommand.

Parameters
cls:type[SupportsTypes] | type[SubcommandOfToNestedText]A SupportsTypes (and SubcommandOfNestedTextTo) or SubcommandOfToNestedText class.
Returns
type[SupportsTypes] | type[SubcommandOfToNestedText]The same cls, with DESCRIPTION_MORE added.
def description_more_for_supports_types(cls: type[SupportsTypes]) -> type[SupportsTypes]: (source)

Add DESCRIPTION_MORE to an nt2 subcommand class.

Makes use of its OTHER_FORMAT and DESCRIPTION_MORE_TMPL attributes, as well as its mixin inheritance.

Parameters
cls:type[SupportsTypes]A SubcommandOfNestedTextTo class which supports types.
Returns
type[SupportsTypes]The same cls, with DESCRIPTION_MORE added.

Add a docstring to a subcommand class, using its DOCSTRING_TMPL and OTHER_FORMAT.

Parameters
cls:type[SubcommandOfNestedTextTo | SubcommandOfToNestedText]A SubcommandOfNestedTextTo or SubcommandOfToNestedText class.
Returns
type[SubcommandOfNestedTextTo | SubcommandOfToNestedText]The same cls, with a docstring added.
def get_ntt_stdout(command: Command, ntt_error_kwargs: dict[str, Any], *args: Any, **kwargs: Any) -> str: (source)

Return the stdout content from the given command invocation.

Parameters
command:CommandThe command to invoke.
ntt_error_kwargs:dict[str, Any]The keyword arguments to pass to the NTTError constructor.
*args:AnyThe positional arguments to pass to the command.
**kwargs:AnyThe keyword arguments to pass to the command.
Returns
strThe stdout content from the given command invocation.
Raises
NTTErrorIf the command fails.
ExceptionIf the command raises a very unexpected exception.
def invoke_ntt_command(command: Command, ntt_error_kwargs: dict[str, Any], *args: Any, **kwargs: Any): (source)

Invoke the command with the given arguments.

Parameters
command:CommandThe command to invoke.
ntt_error_kwargs:dict[str, Any]The keyword arguments to pass to the NTTError constructor.
*args:AnyThe positional arguments to pass to the command.
**kwargs:AnyThe keyword arguments to pass to the command.
Raises
NTTErrorIf the command fails.
def propagate_options_to_subcommand(root: Command, option_cli_names: Sequence[str]): (source)

Add user-supplied opts from the root to its nested command, unless supplied there, too.

Parameters
root:CommandThe root (parent) Command.
option_cli_names:Sequence[str]The names of the options to propagate as they appear on the command line, but without the leading dashes. For example, ['inline-width'].
Raises
NTTErrorIf no subcommand is detected.