.. _jgdv.cli._interface: =================== jgdv.cli._interface =================== .. py:module:: jgdv.cli._interface Enums ----- .. autoapisummary:: jgdv.cli._interface.SectionType_e Protocols --------- .. autoapisummary:: jgdv.cli._interface.ArgParserModel_p jgdv.cli._interface.AssignmentParam_p jgdv.cli._interface.CLIParamProvider_p jgdv.cli._interface.KeyParam_p jgdv.cli._interface.ParamSource_p jgdv.cli._interface.ParamSpec_i jgdv.cli._interface.ParamSpec_p jgdv.cli._interface.PositionalParam_p jgdv.cli._interface.ToggleParam_p Classes ------- .. autoapisummary:: jgdv.cli._interface.ParseReport_d jgdv.cli._interface.ParseResult_d Module Contents =============== .. _jgdv.cli._interface.SectionType_e: .. py:class:: SectionType_e(*args, **kwds) Bases: :py:obj:`enum.Enum` The different types of section a parse machine can process .. py:attribute:: cmd .. py:attribute:: prog .. py:attribute:: sub .. _jgdv.cli._interface.ArgParserModel_p: .. py:class:: ArgParserModel_p Bases: :py:obj:`Protocol` The Model used in a jgdv.cli.arg_parser:ParseMachine to implement specific parsing logic .. py:method:: prepare_for_parse(*, prog, cmds, subs, raw_args) -> .. _jgdv.cli._interface.AssignmentParam_p: .. py:class:: AssignmentParam_p Bases: :py:obj:`Protocol` Interface to mark a parameter as an assignment .. py:method:: _assignment() -> .. _jgdv.cli._interface.CLIParamProvider_p: .. py:class:: CLIParamProvider_p Bases: :py:obj:`Protocol` Things that can provide parameter specs for CLI parsing .. py:method:: param_specs() -> :classmethod: make class parameter specs .. _jgdv.cli._interface.KeyParam_p: .. py:class:: KeyParam_p Bases: :py:obj:`Protocol` Interface to mark a parameter as a key value pair .. py:method:: _keyval() -> .. _jgdv.cli._interface.ParamSource_p: .. py:class:: ParamSource_p Bases: :py:obj:`Protocol` Param Sources are anything that can provide a name and a set of parameters .. py:method:: param_specs() -> :abstractmethod: .. py:property:: name :type: str :abstractmethod: .. _jgdv.cli._interface.ParamSpec_i: .. py:class:: ParamSpec_i Bases: :py:obj:`ParamSpec_p`, :py:obj:`Protocol` Base class for CLI param specs, for type matching when 'consume' is given a list of strs, it can match on the args, and return an updated diction and a list of values it didn't consume .. py:attribute:: _processor :type: ClassVar .. py:attribute:: count :type: int .. py:attribute:: default :type: Any | collections.abc.Callable .. py:attribute:: desc :type: str .. py:attribute:: implicit :type: bool .. py:attribute:: insist :type: bool .. py:attribute:: name :type: str .. py:attribute:: prefix :type: int | str .. py:attribute:: separator :type: str | Literal[False] .. py:attribute:: type_ :type: jgdv.Maybe[type] .. _jgdv.cli._interface.ParamSpec_p: .. py:class:: ParamSpec_p Bases: :py:obj:`Protocol` Base class for CLI param specs, for type matching when 'consume' is given a list of strs, it can match on the args, and return an updated diction and a list of values it didn't consume .. py:method:: consume(args, *, offset = 0) -> .. py:method:: help_str(*, force = False) -> .. py:method:: key_func(x) -> :classmethod: .. py:property:: default_tuple :type: tuple[str, Any] .. py:property:: default_value :type: Any .. py:property:: inverse :type: str .. py:property:: key_str :type: str .. py:property:: key_strs :type: list[str] .. py:property:: repeatable :type: bool .. py:property:: short :type: str .. py:property:: short_key_str :type: jgdv.Maybe[str] .. _jgdv.cli._interface.PositionalParam_p: .. py:class:: PositionalParam_p Bases: :py:obj:`Protocol` Interface to mark a parameter as positional .. py:method:: _positional() -> .. _jgdv.cli._interface.ToggleParam_p: .. py:class:: ToggleParam_p Bases: :py:obj:`Protocol` Interface to mark a parameter as a boolean toggle .. py:method:: _toggle() -> .. _jgdv.cli._interface.ParseReport_d: .. py:class:: ParseReport_d(*, raw, remaining, prog, _help) The returned data of parsing cli args :param raw: the raw args that were used. ieg: sys.argv[:] :param remaining: anything not parsed :param prog: ParseResult_d of base program arguments :param cmds: mapping(cmdName -> [ParseResult_d]) :param subs: mapping(subName -> [ParseResult_d]) :param help: bool .. py:method:: to_dict() -> .. py:attribute:: CmdName :type: TypeAlias :value: str .. py:attribute:: SubName :type: TypeAlias :value: str .. py:attribute:: cmds :type: dict[ParseReport_d.CmdName, tuple[ParseResult_d]] .. py:attribute:: help :type: bool .. py:attribute:: prog :type: ParseResult_d .. py:attribute:: raw :type: tuple[str, Ellipsis] .. py:attribute:: remaining :type: tuple[str, Ellipsis] .. py:attribute:: subs :type: dict[ParseReport_d.SubName, tuple[ParseResult_d]] .. _jgdv.cli._interface.ParseResult_d: .. py:class:: ParseResult_d(name, args = None, ref = None) Simple container for parsed cli information :param name: the name of the spec that parsed this data :param args: mapping of {arg -> data}, including default values it nothing parsing for it :param non_default: set[arg, ...] that actually parsed :param ref: the name of a linked parse result this object extends .. py:method:: to_dict() -> .. py:attribute:: args :type: dict .. py:attribute:: name :type: str .. py:attribute:: non_default :type: set[str] .. py:attribute:: ref :type: jgdv.Maybe[str]