# @generated by usage-argv for `usage __complete_word__ --shell fish`
function __usage_complete_usage
set -l line (commandline -cp)
# `commandline -cp` is already cut at the cursor, so there is nothing to say about where
# the cursor is: the end of what it gives is where the cursor was.
set -l out (command 'usage' __complete_word__ --shell fish --line "$line" 2>/dev/null)
# Built with printf rather than written literally: fish's `case` takes patterns, not
# computed values, and a control byte is not something to spell twice.
set -l marker_any (printf '\x01files')
set -l marker_dirs (printf '\x01dirs')
set -l marker_executables (printf '\x01executables')
set -l marker_commands (printf '\x01commands')
set -l marker_extensions (printf '\x01extensions')
set -l files ""
set -l extensions
for entry in $out
if test "$entry" = "$marker_any"
set files any
else if test "$entry" = "$marker_dirs"
set files dirs
else if test "$entry" = "$marker_executables"
set files executables
else if test "$entry" = "$marker_commands"
set files commands
else if string match -q "$marker_extensions*" -- "$entry"
set files extensions
set extensions (string split (printf '\t') -- "$entry")
set -e extensions[1]
else if test -n "$entry"
# printf, not echo: fish's echo reads a leading -n, -e, -s or -E as its own option,
# so a CLI with a `-n` would have that candidate swallowed on the way to the prompt.
# printf takes its format first and everything after it as data.
printf '%s\n' $entry
end
end
# fish's own path completion, which knows about `~`, variables and remote paths.
switch $files
case any
__fish_complete_path (commandline -ct)
case dirs
__fish_complete_directories (commandline -ct)
case executables
for candidate in (__fish_complete_path (commandline -ct))
set -l value (string split -m 1 (printf '\t') -- $candidate)[1]
if test -d "$value"; or test -x "$value"
printf '%s\n' $candidate
end
end
case commands
__fish_complete_command (commandline -ct)
case extensions
for candidate in (__fish_complete_path (commandline -ct))
set -l value (string split -m 1 (printf '\t') -- $candidate)[1]
if test -d "$value"
printf '%s\n' $candidate
continue
end
for extension in $extensions
if string match -q "*.$extension" -- "$value"
printf '%s\n' $candidate
break
end
end
end
end
end
# `-f` so fish offers no filenames of its own: this CLI says when they belong, and the function
# produces them itself when they do.
complete -c 'usage' -f -a '(__usage_complete_usage)'