mirror of https://github.com/vitalif/phantomjs
Treat all args after the script name as script args
This fixes CapserJS which builds a command line like this: phantomjs bin/bootstrap.js --casper-path=~/capserjs --cli That works on Phantom 1.6 but not on master due to the qcommandline port. Fix by extending qcommandlne to take a ParameterFence flag which causes it to treat any options after a parameter as arguments. Switch "scriptname" to use that so the 1.6 behaviour is restored. http://code.google.com/p/phantomjs/issues/detail?id=551.7
parent
4f7df7073a
commit
23fe144a39
|
@ -62,7 +62,7 @@ static const struct QCommandLineConfigEntry flags[] =
|
|||
{ QCommandLine::Option, '\0', "proxy-type", "Specifies the proxy type, 'http' (default), 'none' (disable completely), or 'socks5'", QCommandLine::Optional },
|
||||
{ QCommandLine::Option, '\0', "script-encoding", "Sets the encoding used for the starting script, default is 'utf8'", QCommandLine::Optional },
|
||||
{ QCommandLine::Option, '\0', "web-security", "Enables web security, 'yes' (default) or 'no'", QCommandLine::Optional },
|
||||
{ QCommandLine::Param, '\0', "script", "Script", QCommandLine::Optional },
|
||||
{ QCommandLine::Param, '\0', "script", "Script", QCommandLine::Flags(QCommandLine::Optional|QCommandLine::ParameterFence)},
|
||||
{ QCommandLine::Param, '\0', "argument", "Script argument", QCommandLine::OptionalMultiple },
|
||||
{ QCommandLine::Switch, 'h', "help", "Shows this message and quits", QCommandLine::Optional },
|
||||
{ QCommandLine::Switch, 'v', "version", "Prints out PhantomJS version", QCommandLine::Optional },
|
||||
|
|
|
@ -224,6 +224,10 @@ QCommandLine::parse()
|
|||
entry.flags = (QCommandLine::Flags) (entry.flags | QCommandLine::Optional);
|
||||
}
|
||||
|
||||
if (entry.flags & QCommandLine::ParameterFence) {
|
||||
allparam = true;
|
||||
}
|
||||
|
||||
emit paramFound(entry.longName, arg);
|
||||
|
||||
if (!(entry.flags & QCommandLine::Multiple))
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
Mandatory = 0x01, /**< mandatory argument, will produce a parse error if not present */
|
||||
Optional = 0x02, /**< optional argument */
|
||||
Multiple = 0x04, /**< argument can be used multiple time and will produce multiple signals. */
|
||||
ParameterFence = 0x08, //**< all arguments after this point are considered parameters, not options. */
|
||||
MandatoryMultiple = Mandatory|Multiple,
|
||||
OptionalMultiple = Optional|Multiple,
|
||||
} Flags;
|
||||
|
|
Loading…
Reference in New Issue