Skip to content

Commit

Permalink
FORGE-614
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Aug 20, 2012
1 parent f8f6ed1 commit 4d5b5cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Expand Up @@ -34,7 +34,7 @@ public CommandParserContext parse(final CommandMetadata command, final Queue<Str
while (!tokens.isEmpty())
{
lastToken = tokens.peek();
if (lastToken.startsWith("-") && command.hasOption(lastToken.replaceAll("^--?", "")))
if (lastToken.startsWith("-") && isValidCommandOption(command, lastToken))
{
break;
}
Expand All @@ -56,4 +56,20 @@ public CommandParserContext parse(final CommandMetadata command, final Queue<Str
return ctx;
}

private boolean isValidCommandOption(final CommandMetadata command, final String lastToken)
{
String name = lastToken.replaceAll("^--?", "");
for (OptionMetadata option : command.getOptions())
{
if (!option.isNamed())
{
continue;
}
if (option.getName().startsWith(name) || (!option.getShortName().isEmpty() && option.getShortName().startsWith(name)))
{
return true;
}
}
return false;
}
}
Expand Up @@ -59,12 +59,6 @@ public int complete(final String buffer, final int cursor, final List<CharSequen
}
}

if ((state.getPlugin() != null) && !state.isFinalTokenComplete() && !state.hasSuggestions()
&& state.isDuplicateBuffer())
{
candidates.add(" ");
}

candidates.addAll(state.getCandidates());

// ensure the completer is triggered always
Expand Down

0 comments on commit 4d5b5cd

Please sign in to comment.