short circuit parsing

6 views
Skip to first unread message

nkabir

unread,
Oct 5, 2010, 11:41:48 AM10/5/10
to argparse-users
Is it possible to short-circuit parsing? For example, can I use an
argument that will cause parsing to stop, not throw any errors and
forward the arguments to another method?

Steven Bethard

unread,
Oct 8, 2010, 10:32:17 AM10/8/10
to argpars...@googlegroups.com

There's no easy way to do this. Can you describe why you're trying to
do this? If we know more of what you're trying to accomplish (what you
want your command line API to look like) we might be able to offer
some workarounds.

Steve
--
Where did you get that preposterous hypothesis?
Did Steve tell you that?
        --- The Hiphopopotamus

nkabir

unread,
Oct 8, 2010, 10:52:52 AM10/8/10
to argparse-users
I managed to accomplish my goal by creating a custom action. I wanted
to do the following:

Support normal command line invocation
mycommand -p pval -q qval -r rval

Support interactive command line invocation
mycommand -i
please enter p: pval
please enter q: qval
please enter r: rval

(invokes mycommand -p pval -q qval -r rval)

Cheers,
--Norm

Steven Bethard

unread,
Oct 8, 2010, 11:05:33 AM10/8/10
to argpars...@googlegroups.com
On Fri, Oct 8, 2010 at 4:52 PM, nkabir <nka...@gmail.com> wrote:
> I managed to accomplish my goal by creating a custom action. I wanted
> to do the following:
>
> Support normal command line invocation
> mycommand -p pval -q qval -r rval
>
> Support interactive command line invocation
> mycommand -i
>  please enter p: pval
>  please enter q: qval
>  please enter r: rval
>
> (invokes mycommand -p pval -q qval -r rval)

Cool, yep, sounds like a custom action was the right way to go with
this. Glad you found a way.

Reply all
Reply to author
Forward
0 new messages