[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`?

On 16Oct2020 10:59, Samuel Marks <samuelmarks at> 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)


    Usage: .......
      --optimizer name[,param=value...]
        Specify use of the named optimizer with optional additional
          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.)

Cameron Simpson <cs at>