Skip to content

Commit

Permalink
[bash] use filtering function to add options for commands based on wh…
Browse files Browse the repository at this point in the history
…ether or not they allow duplicates
  • Loading branch information
sharder996 committed Sep 29, 2023
1 parent 6e44e02 commit 8eeba16
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions completions/bash/multipass
Original file line number Diff line number Diff line change
Expand Up @@ -198,49 +198,45 @@ _multipass_complete()

if [[ "${multipass_cmds}" =~ " ${cmd} " || "${multipass_cmds}" =~ ^${cmd} || "${multipass_cmds}" =~ \ ${cmd}$ ]];
then
opts="--help --verbose"
_add_nonrepeating_args "--help"
opts="${opts} --verbose"
fi

case "${cmd}" in
"exec")
opts="${opts} --working-directory --no-map-working-directory"
;;
"info")
opts="${opts} --all --format"
_add_nonrepeating_args "--all --format"
;;
"list"|"ls")
opts="${opts} --format"
;;
"networks")
opts="${opts} --format"
"list"|"ls"|"networks"|"aliases")
_add_nonrepeating_args "--format"
;;
"delete")
opts="${opts} --all --purge"
_add_nonrepeating_args "--all --purge"
;;
"launch")
opts="${opts} --cpus --disk --memory --name --cloud-init --network --bridged --mount"
_add_nonrepeating_args "--cpus --disk --memory --name --cloud-init --bridged --mount"
opts="${opts} --network --mount"
;;
"mount")
opts="${opts} --gid-map --uid-map"
;;
"recover"|"start"|"suspend"|"restart")
opts="${opts} --all"
_add_nonrepeating_args "--all"
;;
"stop")
opts="${opts} --all --cancel --time"
_add_nonrepeating_args "--all --cancel --time"
;;
"find")
opts="${opts} --show-unsupported --force-update --format"
;;
"aliases")
opts="${opts} --format"
_add_nonrepeating_args "--show-unsupported --force-update --format"
;;
"unalias")
_multipass_aliases
_add_nonrepeating_args $multipass_aliases
;;
"transfer"|"copy-files")
opts="${opts} --parents --recursive"
_add_nonrepeating_args "--parents --recursive"
;;
esac

Expand Down

0 comments on commit 8eeba16

Please sign in to comment.