Question:
How a app should parse command line when there is a Command after a double dash? (Not duplicated of this and this)
I know what will double dash normally do:
A -- signals the end of options and disables further option processing. Any arguments after the -- are treated as file‐ names and arguments. An argument of - is equivalent to --
So it set the following things as arguments, for example:
myapp -f <args> ...
Then $ myapp -f -- -a -b
will treat -a
and -b
as arguments of -f
, instead of Flags
But what will happen when an app required:
myapp cmd <arg> -f <args>...
And the command line is $ myapp -f -- test cmd sth
, Should it parsed as:
myapp
received a-f
Flag with argumentstest
,cmd
andsth
- or
myapp
received acmd
Command followed bysth
, a-f
with argumenttest
I'm writing a command line parser for python so I need to know how it should behave.
Thx a lot :)
See Question&Answers more detail:os