.. _jgdv.cli.parse_machine: ====================== jgdv.cli.parse_machine ====================== .. py:module:: jgdv.cli.parse_machine .. autoapi-nested-parse:: Provdes the Main ArgParser_p Protocol, and the ParseMachineBase StateMachine. ParseMachineBase descibes the state progression to parse arguments, while jgdv.cli.arg_parser.CLIParser adds the specific logic to states and transitions Classes ------- .. autoapisummary:: jgdv.cli.parse_machine.ParseMachine Module Contents =============== .. _jgdv.cli.parse_machine.ParseMachine: .. py:class:: ParseMachine(parser = None, max = MAX_STAGES) Bases: :py:obj:`statemachine.StateMachine` Implemented Parse State Machine __call__ with: args : list[str] -- the cli args to parse (ie: from sys.argv) prog : list[ParamSpec_i] -- specs of the top level program cmds : list[ParamSource_p] -- commands that can provide their parameters subs : dict[str, list[ParamSource_p]] -- a mapping from commands -> subcommands that can provide parameters A cli call will be of the form: {proghead} {prog [kw]args} {cmd} {cmd[kw]args}* [{subs} {subs[kw]args} [-- {subs} {subargs}]* ]? (--help)? eg: doot -v list -by-group a b c --help doot run basic::task -quick --value=2 --help Will raise a jgdv.cli.errors.ParseError on failure .. py:method:: on_enter_state(source, event, target) -> .. py:method:: on_exit_state() -> .. py:attribute:: Cleanup .. py:attribute:: Cmd .. py:attribute:: End .. py:attribute:: Head .. py:attribute:: Help .. py:attribute:: Kwargs .. py:attribute:: Posargs .. py:attribute:: Prepare .. py:attribute:: Prog .. py:attribute:: Report .. py:attribute:: Section .. py:attribute:: Section_end .. py:attribute:: Separator .. py:attribute:: Start .. py:attribute:: Sub .. py:attribute:: count :value: 0 .. py:attribute:: finish .. py:attribute:: max_attempts :value: 200 .. py:attribute:: parse .. py:attribute:: progress .. py:attribute:: setup