CLI parsing—with `--help` text—`--foo bar`, how to give additional parameters to `bar`?
Cameron Simpson
cs at cskk.id.au
Thu Oct 15 22:01:26 EDT 2020
On 16Oct2020 10:59, Samuel Marks <samuelmarks at gmail.com> wrote:
>--optimizer Adam,learning_rate=0.01,something_else=3
>
>That syntax isn’t so bad! =]
>
>How would you suggest the help text for this looks? (don’t worry about
>implementation, just what goes to stdout/stderr)
Maybe:
Usage: .......
................
--optimizer name[,param=value...]
Specify use of the named optimizer with optional additional
parameters:
learning_rate Scale of gullibility, a float.
something_else Another tuning thing,
...
which is the style I use in my own usage messages. Possibly also allow the
"=value" to be optional (where sensible per parameter), since it is so easy.
>PS: Yeah I used square brackets for my Bash arrays
By the time I want real arrays in my shell scripts I'm often verging on the
regime where it's time to transition to a more expressive language. Like
Python :-) (Unless of course you're using a bunch of shell control constructs
like pipes, which are succintly written in the shell.)
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list