Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/completion-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ _{{app_name}}_yargs_completions()
args=("\${COMP_WORDS[@]}")
# ask yargs to generate completions.
type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
# see https://stackoverflow.com/a/40944195/7080036 for the spaces-handling awk
mapfile -t type_list < <({{app_path}} --get-yargs-completions "\${args[@]}")
mapfile -t COMPREPLY < <(compgen -W "$( printf '%q ' "\${type_list[@]}" )" -- "\${cur_word}" |
awk '/ / { print "\\""$0"\\"" } /^[^ ]+$/ { print $0 }')
# if no match was found, fall back to filename completion
if [ \${#COMPREPLY[@]} -eq 0 ]; then
Expand Down