git.net

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


Samuel Marks wrote at 2020-10-16 10:09 +1100:
>Yes it?s my module, and I?ve been using argparse
>https://github.com/SamuelMarks/ml-params
>
>No library I?ve found provides a solution to CLI argument parsing for my
>use-case.

Do you know that with `argparse` you can specify how many arguments an option
expects? Thus, it should be quite easily possible to
have --opt <o1> <o2> ...
Do you know that you can define new `Action`s for `argparse`?
This way, you could properly process `--opt <o1>,<o2>, ...`.