pypyr.parser.keyvaluepairs permalink

pass key value pairs from cli to pipeline permalink

Takes key=value pair string from cli arg input and initialize context with a dictionary where each pair becomes a dictionary element.

Escape literal spaces with single or double quotes.

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

# ./keyvaluepairs-parser.yaml
context_parser: pypyr.parser.keyvaluepairs
  - pypyr.steps.debug # prints at log level <=20

You can then pass key-value pairs from the cli to the pipeline to initialize context. Notice that you can have both keys and values with spaces by using either single or double quotes.

$ pypyr keyvaluepairs-parser param1=value1 param2='value 2' "param 3"=123 --log 20
{'param 3': '123', 'param1': 'value1', 'param2': 'value 2'}

see also

last updated on .