Skip to content

Commit

Permalink
fix(command): only generate argument completions for types that have …
Browse files Browse the repository at this point in the history
…completions (#81)
  • Loading branch information
c4spar committed Sep 3, 2020
1 parent 7d7b75f commit 1998108
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions command/completions/zsh-completions-generator.ts
Expand Up @@ -86,10 +86,7 @@ function _${replaceSpecialChars(path)}() {` +
(!command.getParent()
? `
# shellcheck disable=SC2034
local context state state_descr line
# shellcheck disable=SC2034
typeset -A opt_args`
local state`
: "") +
this.generateCommandCompletions(command, path) +
this.generateSubCommandCompletions(command, path) +
Expand Down Expand Up @@ -130,7 +127,7 @@ function _${replaceSpecialChars(path)}() {` +

const action = this.addAction(arg, completionsPath);

if (action) {
if (action && command.getCompletion(action.name)) {
completions += `\n __${
replaceSpecialChars(this.cmd.getName())
}_complete ${action.arg.name} ${action.arg.action} ${action.cmd}`;
Expand Down Expand Up @@ -182,7 +179,12 @@ function _${replaceSpecialChars(path)}() {` +
argsCommand += ` \\\n ${options.join(" \\\n ")}`;
}

if (command.hasCommands(false) || command.hasArguments()) {
if (
command.hasCommands(false) || (
command.getArguments()
.filter((arg) => command.getCompletion(arg.name)).length
)
) {
argsCommand += ` \\\n '${++argIndex}: :_commands'`;
}

Expand Down

0 comments on commit 1998108

Please sign in to comment.