[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CLI parsing—with `--help` text—`--foo bar`, how to give additional parameters to `bar`?

Previously I have solved related problems with explicit `-}` and `-{`
(or `-b`) as in `nginxctl`:
$ python -m nginxctl serve --temp_dir '/tmp' \
            -b 'server' \
              --server_name 'localhost' --listen '8080' \
              -b location '/' \
                --root '/tmp/wwwroot' \
              -} \
nginx is running. Stop with: /usr/local/bin/nginx -c /tmp/nginx.conf -s stop

To illustrate the issue, using `ml-params` and ml-params-tensorflow:
$ python -m ml_params --engine 'tensorflow' train --help

usage: python -m ml_params train [-h]


Run the training loop for your ML pipeline.

optional arguments:
  -h, --help            show this help message and exit
  --optimizer {Adadelta,Adagrad,Adam,Adamax,Ftrl,Nadam,RMSprop}
                        The optimizer
Idea: preprocess `sys.argv` so that this syntax would work
`--optimizer Adam[learning_rate=0.01]`*

*square rather than round so as not to require escape characters or
quoting in `sh`

Unfortunately this approach wouldn't give nice `--help` text.

What's the right solution here?


Samuel Marks
Charity <> | consultancy
<> | open-source <> |
LinkedIn <>