context parsers
A context parser allows you to customize how you want to pass cli arguments to your pipeline. pypyr has a whole bunch of ready-made built-in context parsers to make your life easier.
Making your own custom context-parser is super easy too.
# everything after mypipeline goes to the context_parser
$ pypyr mypipeline these are all context input arguments
$ pypyr mypipeline key1=value2 key2="value 2"
A context_parser
parses the pypyr command’s context input arguments.
This is all the positional arguments after the pipeline-name from the
command line.
The chances are pretty good that the context_parser
will take the
context command arguments and put in into the pypyr context.
The pypyr context
is a dictionary that is in scope for the duration of the entire pipeline. The
context_parser
can initialize the context. Any step in the pipeline can add,
edit or remove items from the context dictionary.
built-in context parsers
title | example cli input |
---|---|
argskwargs | pypyr my-pipeline arg1 arg2 k1=value1 k2="value 2" |
dict | pypyr my-pipeline param1=value1 param2="value 2" param3=value3 |
json | pypyr my-pipeline {"key1": "value 1", "key2": 123} |
jsonfile | pypyr my-pipeline ./path/sample.json |
keys | pypyr my-pipeline param1 'par am2' param3 |
keyvaluepairs | pypyr my-pipeline param1=value1 param2="value 2" "param 3"=value3 |
list | pypyr my-pipeline param1 param2 param3 |
string | pypyr my-pipeline arbitrary string here |
tomlfile | pypyr my-pipeline ./path/sample.toml |
yamlfile | pypyr my-pipeline ./path/sample.yaml |