Re: Re: CLI parsing—with `--help` text—`--foo bar`, how to give additional parameters to `bar`?
Yeah I've played with custom actions before
But this would only help in one phase, the important phase of
providing help text will need to be provided out-of-argparse and
(like my trivial absl alternative, exposing a function which takes an
argparse instance and returns an argparse instance)
The only hack remaining is that I have to pass through `sys.argv` at
least once before giving it to argparse. I wonder if there's a way to
not need to explicitly go through it at all?
[I didn't know `getopt` was exposed otherwise I'd use that <like I
sometimes do in C>, but there has to be a solution just using
Charity <https://sydneyscientific.org> | consultancy
<https://offscale.io> | open-source <https://github.com/offscale> |
Charity | consultancy | open-source | LinkedIn
On Fri, Oct 16, 2020 at 3:47 PM Dieter Maurer <dieter at handshake.de> wrote:
> Samuel Marks wrote at 2020-10-16 10:09 +1100:
> >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
> 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>, ...`.