pypyr.parser.string permalink

put all cli input args into a single string permalink

Takes any arbitrary input from the cli input args and concatenate into a single string argString to initialize context.

If you have multiple sequential literal spaces right next to each other, escape these with single or double quotes.

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

# ./string-parser.yaml
context_parser: pypyr.parser.string
steps:
  - pypyr.steps.debug # prints at log level <=20
  - name: pypyr.steps.echo
    comment: use argString in format expression
    in:
        echoMe: "this came from the cli: {argString}"

You can then pass any given string, including nothing, from the cli to the pipeline to initialize context:

$ pypyr string-parser --log 20
{'argString': None}
this came from the cli: None

$ pypyr string-parser arbitrary words here --log 20
{'argString': 'arbitrary words here'}
this came from the cli: arbitrary words here

$ pypyr string-parser a b c --log 20
{'argString': 'a b c'}
this came from the cli: a b c

$ pypyr string-parser "a " " b" 'c' --log 20
{'argString': 'a   b c'}
this came from the cli: a   b c

$ pypyr string-parser "a b  b c" --log 20
{'argString': 'a b  b c'}
this came from the cli: a b  b c

see also

last updated on .