1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 11:27:58 +01:00

Emit completion messages for arg parser errors.

This commit is contained in:
Kris Maglione
2008-11-28 11:44:58 +00:00
parent 18cf334054
commit ceaa5d913e
2 changed files with 13 additions and 9 deletions

View File

@@ -491,6 +491,14 @@ function Commands() //{{{
args.completeArg = 0;
}
function echoerr(error)
{
if (complete)
complete.message = error;
else
liberator.echoerr(error);
}
outer:
while (i < str.length || complete)
{
@@ -565,13 +573,11 @@ function Commands() //{{{
arg = type.parse(arg);
if (arg == null || arg == NaN)
{
echoerr("Invalid argument for " + type.description + "option: " + optname);
if (complete)
complete.highlight(args.completeStart, count - 1, "SPELLCHECK");
else
{
liberator.echoerr("Invalid argument for " + type.description + "option: " + optname);
return null;
}
}
}
@@ -580,13 +586,11 @@ function Commands() //{{{
{
if (opt[2].call(this, arg) == false)
{
echoerr("Invalid argument for option: " + optname);
if (complete)
complete.highlight(args.completeStart, count - 1, "SPELLCHECK");
else
{
liberator.echoerr("Invalid argument for option: " + optname);
return null;
}
}
}
@@ -678,8 +682,7 @@ function Commands() //{{{
else if (args.length == 1 && (argCount == "0") ||
args.length > 1 && /^[01?]$/.test(argCount))
{
if (!complete)
liberator.echoerr("E488: Trailing characters");
echoerr("E488: Trailing characters");
return null;
}

View File

@@ -355,7 +355,8 @@ const liberator = (function () //{{{
commands.add(["loadplugins", "lpl"],
"Load all plugins immediately",
function () { liberator.loadPlugins(); });
function () { liberator.loadPlugins(); },
{ argCount: "0" );
commands.add(["norm[al]"],
"Execute Normal mode commands",