pypyr.parser.list permalink

parse cli input args into list permalink

Append each input argument into a list argList to initialize context.

Escape literal spaces with single or double quotes.

Given a pipeline like this, arbitrarily saved as ./list-parser.yaml:

# ./list-parser.yaml
context_parser: pypyr.parser.list
steps:
  - pypyr.steps.debug # prints at log level <=20
  - name: pypyr.steps.echo
    comment: the args passed into the pypyr with list parser 
             end up as a list in context under key argList
    in:
      echoMe: "the 2nd thing on the input list is: {argList[1]}"

Each argument you pass via the cli will now be in the argList list:

$ pypyr list-parser eggs bacon ham --log 20
{'argList': ['eggs', 'bacon', 'ham']}
the 2nd thing on the input list is: bacon

see also

last updated on .