Vagrant completion updates

Improve vagrant completions for some commands to avoid spurious
completions, and add completions for some missing Vagrant commands.

Fixes #1748.
This commit is contained in:
Diego Zamboni 2014-10-10 14:50:05 -07:00 committed by Kevin Ballard
parent becdc8b4fc
commit d982f2a575

View file

@ -1,38 +1,30 @@
# vagrant autocompletion # vagrant autocompletion
function __fish_vagrant_no_command --description 'Test if vagrant has yet to be given the main command' function __fish_vagrant_no_command --description 'Test if vagrant has yet to be given the main command'
set cmd (commandline -opc) set -l cmd (commandline -opc)
if [ (count $cmd) -eq 1 ] test (count $cmd) -eq 1
return 0
end
return 1
end end
function __fish_vagrant_using_command function __fish_vagrant_using_command
set cmd (commandline -opc) set -l cmd (commandline -opc)
if [ (count $cmd) -gt 1 ] set -q cmd[2]; and test "$argv[1]" = $cmd[2]
if [ $argv[1] = $cmd[2] ]
return 0
end
end
return 1
end end
function __fish_vagrant_using_subcommand function __fish_vagrant_using_command_and_no_subcommand
set cmd (commandline -opc) set -l cmd (commandline -opc)
set cmd_main $argv[1] test (count $cmd) -eq 2; and test "$argv[1]" = "$cmd[2]"
set cmd_sub $argv[2] end
if [ (count $cmd) -gt 2 ] function __fish_vagrant_using_subcommand --argument-names cmd_main cmd_sub
if [ $cmd_main = $cmd[2] ]; and [ $cmd_sub = $cmd[3] ] set -l cmd (commandline -opc)
return 0 set -q cmd[3]; and test "$cmd_main" = $cmd[2] -a "$cmd_sub" = $cmd[3]
end
end
return 1
end end
function __fish_vagrant_boxes --description 'Lists all available Vagrant boxes' function __fish_vagrant_boxes --description 'Lists all available Vagrant boxes'
command vagrant box list set -l IFS \n\ \t
command vagrant box list | while read -l name _
echo $name
end
end end
# --version and --help are always active # --version and --help are always active
@ -41,17 +33,28 @@ complete -c vagrant -f -s h -l help -d 'Print the help and exit'
# box # box
complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'box' -d 'Manages boxes' complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'box' -d 'Manages boxes'
complete -c vagrant -n '__fish_vagrant_using_command box' -a add -d 'Adds a box' complete -c vagrant -n '__fish_vagrant_using_command_and_no_subcommand box' -a add -d 'Adds a box'
complete -c vagrant -f -n '__fish_vagrant_using_command box' -a list -d 'Lists all the installed boxes' complete -c vagrant -f -n '__fish_vagrant_using_command_and_no_subcommand box' -a list -d 'Lists all the installed boxes'
complete -c vagrant -f -n '__fish_vagrant_using_command box' -a remove -d 'Removes a box from Vagrant' complete -c vagrant -f -n '__fish_vagrant_using_command_and_no_subcommand box' -a remove -d 'Removes a box from Vagrant'
complete -c vagrant -f -n '__fish_vagrant_using_command box' -a repackage -d 'Repackages the given box for redistribution' complete -c vagrant -f -n '__fish_vagrant_using_command_and_no_subcommand box' -a repackage -d 'Repackages the given box for redistribution'
complete -c vagrant -f -n '__fish_vagrant_using_subcommand box add' -l provider -d 'Verifies the box with the given provider' complete -c vagrant -f -n '__fish_vagrant_using_subcommand box add' -l provider -d 'Verifies the box with the given provider'
complete -c vagrant -f -n '__fish_vagrant_using_subcommand box remove' -a '(__fish_vagrant_boxes)' complete -c vagrant -f -n '__fish_vagrant_using_subcommand box remove' -a '(__fish_vagrant_boxes)'
# connect
complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'connect' -d 'Connect to a remotely shared Vagrant environment'
complete -c vagrant -f -n '__fish_vagrant_using_command connect' -l disable-static-ip -d 'No static IP, only a SOCKS proxy'
complete -c vagrant -f -n '__fish_vagrant_using_command connect' -l static-ip -r -d 'Manually override static IP chosen'
complete -c vagrant -f -n '__fish_vagrant_using_command connect' -l ssh -d 'SSH into the remote machine'
# destroy # destroy
complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'destroy' -d 'Destroys the running machine' complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'destroy' -d 'Destroys the running machine'
complete -c vagrant -f -n '__fish_vagrant_using_command destroy' -s f -l force -d 'Destroy without confirmation' complete -c vagrant -f -n '__fish_vagrant_using_command destroy' -s f -l force -d 'Destroy without confirmation'
# global-status
complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'global-status' -d 'Global status of Vagrant environments'
complete -c vagrant -f -n '__fish_vagrant_using_command global-status' -l prune -d 'Prune invalid entries'
# gem # gem
complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'gem' -d 'Install Vagrant plugins through ruby gems' complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'gem' -d 'Install Vagrant plugins through ruby gems'
@ -63,6 +66,11 @@ complete -c vagrant -f -n '__fish_vagrant_using_command halt' -s f -l force -d '
complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'init' -d 'Initializes the Vagrant environment' complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'init' -d 'Initializes the Vagrant environment'
complete -c vagrant -f -n '__fish_vagrant_using_command init' -a '(__fish_vagrant_boxes)' complete -c vagrant -f -n '__fish_vagrant_using_command init' -a '(__fish_vagrant_boxes)'
# login
complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'login' -d 'Log in to Vagrant Cloud'
complete -c vagrant -f -n '__fish_vagrant_using_command login ' -s c -l check -d "Only checks if you're logged in"
complete -c vagrant -f -n '__fish_vagrant_using_command login ' -s k -l logout -d "Logs you out if you're logged in"
# package # package
complete -c vagrant -n '__fish_vagrant_no_command' -a 'package' -d 'Packages a running machine into a reusable box' complete -c vagrant -n '__fish_vagrant_no_command' -a 'package' -d 'Packages a running machine into a reusable box'
complete -c vagrant -n '__fish_vagrant_using_command package' -l base -d 'Name or UUID of the virtual machine' complete -c vagrant -n '__fish_vagrant_using_command package' -l base -d 'Name or UUID of the virtual machine'
@ -81,6 +89,9 @@ complete -c vagrant -n '__fish_vagrant_using_command plugin' -a uninstall -r -d
complete -c vagrant -n '__fish_vagrant_no_command' -a 'provision' -d 'Runs configured provisioners on the running machine' complete -c vagrant -n '__fish_vagrant_no_command' -a 'provision' -d 'Runs configured provisioners on the running machine'
complete -c vagrant -n '__fish_vagrant_using_command provision' -l provision-with -r -d 'Run only the given provisioners' complete -c vagrant -n '__fish_vagrant_using_command provision' -l provision-with -r -d 'Run only the given provisioners'
# rdp
complete -c vagrant -n '__fish_vagrant_no_command' -a 'rdp' -d 'Connects to machine via RDP'
# reload # reload
complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'reload' -d 'Restarts the running machine' complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'reload' -d 'Restarts the running machine'
complete -c vagrant -f -n '__fish_vagrant_using_command reload' -l no-provision -r -d 'Provisioners will not run' complete -c vagrant -f -n '__fish_vagrant_using_command reload' -l no-provision -r -d 'Provisioners will not run'
@ -89,6 +100,18 @@ complete -c vagrant -f -n '__fish_vagrant_using_command reload' -l provision-wit
# resume # resume
complete -c vagrant -x -n '__fish_vagrant_no_command' -a 'resume' -d 'Resumes a previously suspended machine' complete -c vagrant -x -n '__fish_vagrant_no_command' -a 'resume' -d 'Resumes a previously suspended machine'
# share
complete -c vagrant -n '__fish_vagrant_no_command' -a 'share' -d 'Share your Vagrant environment with anyone in the world'
complete -c vagrant -n '__fish_vagrant_using_command share' -l disable-http -d 'Disable publicly visible HTTP endpoint'
complete -c vagrant -n '__fish_vagrant_using_command share' -l domain -r -d 'Domain the share name will be a subdomain of'
complete -c vagrant -n '__fish_vagrant_using_command share' -l http -r -d 'Local HTTP port to forward to'
complete -c vagrant -n '__fish_vagrant_using_command share' -l https -r -d 'Local HTTPS port to forward to'
complete -c vagrant -n '__fish_vagrant_using_command share' -l name -r -d 'Specific name for the share'
complete -c vagrant -n '__fish_vagrant_using_command share' -l ssh -d "Allow 'vagrant connect --ssh' access"
complete -c vagrant -n '__fish_vagrant_using_command share' -l ssh-no-password -d "Key won't be encrypted with --ssh"
complete -c vagrant -n '__fish_vagrant_using_command share' -l ssh-port -r -d 'Specific port for SSH when using --ssh'
complete -c vagrant -n '__fish_vagrant_using_command share' -l ssh-once -d "Allow 'vagrant connect --ssh' only one time"
# ssh # ssh
complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'ssh' -d 'SSH into a running machine' complete -c vagrant -f -n '__fish_vagrant_no_command' -a 'ssh' -d 'SSH into a running machine'
complete -c vagrant -f -n '__fish_vagrant_using_command ssh' -s c -l command -r -d 'Executes a single SSH command' complete -c vagrant -f -n '__fish_vagrant_using_command ssh' -s c -l command -r -d 'Executes a single SSH command'