Positional arguments?

139 views
Skip to first unread message

theonlygusti

unread,
Jan 26, 2017, 3:41:10 AM1/26/17
to jcommander
Is it possible to specify named arguments that are recognised based on position rather than having an option before?

E.g.

main <name>

Normally you'd have to call like this with jcommander:

main name whatever

But is it possible to be able to do this

main whatever

And then

Commander.name == "whatever"

Cédric Beust ♔

unread,
Jan 26, 2017, 12:35:24 PM1/26/17
to jcommander
You can just pick all these parameters in your main parameter and dispatch them from there, can't you?


-- 
Cédric


--
You received this message because you are subscribed to the Google Groups "jcommander" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

theonlygusti

unread,
Jan 27, 2017, 4:09:35 AM1/27/17
to jcommander, ced...@beust.com
What do you mean? I don't quite understand.

In the final tool, I'd like to create command syntaxes like this:

main <command> <itemName>

main hide file.py

Or things like

main <command> <itemName> <attribute>

main set brightness 100 

On Thursday, 26 January 2017 17:35:24 UTC, Cédric Beust ♔ wrote:
You can just pick all these parameters in your main parameter and dispatch them from there, can't you?


-- 
Cédric


On Thu, Jan 26, 2017 at 12:41 AM, theonlygusti <gbake...@gmail.com> wrote:
Is it possible to specify named arguments that are recognised based on position rather than having an option before?

E.g.

main <name>

Normally you'd have to call like this with jcommander:

main name whatever

But is it possible to be able to do this

main whatever

And then

Commander.name == "whatever"

--
You received this message because you are subscribed to the Google Groups "jcommander" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+...@googlegroups.com.

theonlygusti

unread,
Feb 9, 2017, 5:18:20 AM2/9/17
to jcommander, ced...@beust.com
Hey do you mind explaining what you mean?

In the final tool, I'd like to create command syntaxes like this:

main <command> <itemName>

main hide file.py

Or things like

main <command> <option> <attribute>

main set brightness 100

And so access them in my code like setCommand.option // "brightness"

On Thursday, 26 January 2017 17:35:24 UTC, Cédric Beust ♔ wrote:
You can just pick all these parameters in your main parameter and dispatch them from there, can't you?


-- 
Cédric


On Thu, Jan 26, 2017 at 12:41 AM, theonlygusti <gbake...@gmail.com> wrote:
Is it possible to specify named arguments that are recognised based on position rather than having an option before?

E.g.

main <name>

Normally you'd have to call like this with jcommander:

main name whatever

But is it possible to be able to do this

main whatever

And then

Commander.name == "whatever"

--
You received this message because you are subscribed to the Google Groups "jcommander" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcommander+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages