historical/moneyrocket.git/contrib/completions/fish/moneyrocket-qt.fish
2024-01-16 11:20:27 -06:00

35 lines
1.2 KiB
Fish

# Disable files from being included in completions by default
complete --command moneyrocket-qt --no-files
# Extract options
function __fish_moneyrocketqt_get_options
argparse 'nofiles' -- $argv
set --local cmd (commandline -opc)[1]
set --local options
if set -q _flag_nofiles
set --append options ($cmd -help-debug | string match -r '^ -.*' | string replace -r ' -' '-' | string replace -r '=.*' '=' | string match --invert -r '^.*=$')
else
set --append options ($cmd -help-debug | string match -r '^ -.*' | string replace -r ' -' '-' | string replace -r '=.*' '=' | string match -r '^.*=$')
end
for option in $options
echo $option
end
end
# Add options with file completion
complete \
--command moneyrocket-qt \
--arguments "(__fish_moneyrocketqt_get_options)"
# Enable file completions only if the commandline now contains a `*.=` style option
complete -c moneyrocket-qt \
--condition 'string match --regex -- ".*=" (commandline -pt)' \
--force-files
# Add options without file completion
complete \
--command moneyrocket-qt \
--arguments "(__fish_moneyrocketqt_get_options --nofiles)"