1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 05:27:59 +01:00

allow -option foo in adition to -option=foo

This commit is contained in:
Martin Stubenschrott
2007-10-18 18:30:08 +00:00
parent 177a191940
commit 66c640578a

View File

@@ -271,8 +271,9 @@ function Commands() //{{{
if (!options)
options = [];
var invalid = false;
var arg = null;
var count = 0;
var count = 0; // the length of the argument
var i = 0;
outer:
while(i < str.length)
@@ -293,11 +294,11 @@ function Commands() //{{{
optname = options[opt][0][name];
if (sub.indexOf(optname) == 0)
{
var invalid = false;
// no value to the option
if (optname.length >= sub.length || /\s/.test(sub[optname.length]))
{
invalid = false;
arg = null;
// no value to the option
if (optname.length >= sub.length)
{
count = 0;
}
else if (sub[optname.length] == "=")
@@ -308,6 +309,18 @@ function Commands() //{{{
count++; // to compensate the "=" character
}
else if (options[opt][1] != OPTION_NOARG && /\s/.test(sub[optname.length]))
{
[count, arg] = getNextArg(sub.substr(optname.length + 1));
if (count == -1)
return { error: "Invalid argument for option " + optname, opts: [], args: [] }
// if we add the argument to an option after a space, it MUST not be empty
if (arg.length == 0)
arg = null;
count++; // to compensate the " " character
}
else
{
// this isn't really an option as it has trailing characters, parse it as an argument