[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:09, Samuel Marks <samuelmarks at> wrote:
>Yes it?s my module, and I?ve been using argparse
>No library I?ve found provides a solution to CLI argument parsing for my
>So I?ll write one. But what should it look like, syntactically and

I would make it look like argparse, if you're using argparse already. 
Can argparse be subclassed, eg to override some internal 
option-gathering method?

In particular, I would not invent yet another command line syntax.

I'd stick with the common -a and --long-name style, maybe using the -{ -} 
stuff you cited from nginx if it meets your needs. As with any 
bracketing syntax, you may one day find yourself needing to embed the 
literal end-bracket symbol in your command line one day, and thus may 
need some kind of escaping notion ("no! not closing the brackets yet!").

I can't offer mch specific advice on argparse, I use getopt myself.

Cameron Simpson <cs at>