[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
thrown in

(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

Samuel Marks
Charity <> | consultancy
<> | open-source <> |
LinkedIn <>

Samuel Marks
Charity | consultancy | open-source | LinkedIn

On Fri, Oct 16, 2020 at 3:47 PM Dieter Maurer <dieter at> 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
> >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>, ...`.