fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
a9618477e
master
1# Completions for vagrant, a vm/container management thing. 2# Docs are at https://www.vagrantup.com/docs/cli/. 3# 4# Apparently options can only come after commands, with the exception of "-v" and "-h", which are effectively commands. 5set -l commands box cloud connect destroy\ 6 docker-{ exec, logs, run} \ 7 global-status halt help init list-commands login\ 8 package plugin provision push rdp reload resume\ 9 rsync rsync-auto share snapshot ssh ssh-config\ 10 status suspend up version\ 11 port powershell winrm{, -config} 12 13set -l box_commands add help list outdated prune remove repackage update 14set -l cloud_commands auth box search provider publish version 15set -l plugin_commands install license list uninstall update 16set -l snapshot_commands delete list pop push restore save 17 18function __fish_print_vagrant_state 19# Find a .vagrant file/directory above $PWD 20set -l root 21set -l dir( pwd -P) 22while test $dir != / 23if test -d $dir .vagrant-o -f $dir .vagrant 24echo $dir .vagrant 25return 0 26end 27# Go up one directory 28set dir( string replace -r'[^/]*/?$' '' $dir ) 29end 30return 1 31end 32 33function __fish_vagrant_machines 34if set -l state( __fish_print_vagrant_state ) 35test -d " $state " ;or return 36set -l machines$state /machines/* 37string replace --$state /machines/'' $machines 38end 39end 40 41function __fish_vagrant_boxes 42set -l vhome$VAGRANT_HOME /boxes 43set -q vhome[ 1 ] ;or set vhome ~/.vagrant.d/boxes 44set -l boxes$vhome /* 45string replace --$vhome /'' $boxes | string replace -- -VAGRANTSLASH- / 46end 47 48function __fish_vagrant_need_command -V commands 49argparse -s h/help v/version --( commandline -xpc)[ 2..-1] 2> /dev/null 50or return 51if set -q _flag_help[ 1 ] ;or set -q _flag_help[ 1 ] 52return 1 53end 54if set -q argv[ 1 ] 55echo $argv 56return 1 57end 58return 0 59end 60 61function __fish_vagrant_using_command 62set -l cmd( __fish_vagrant_need_command ) 63contains --$cmd [ 1 ] $argv 64end 65 66function __fish_vagrant_box_need_command 67set -l cmd( __fish_vagrant_need_command ) 68test " $cmd [ 1 ] " = box2> /dev/null 69or return 1 70set -e cmd[ 1 ] 71 72# Not all of these are valid for all subcommands, but that's not important here. 73# Yes, none of these have a short version. 74set -l opts b-box-version= c-cacert= C-capath= 1-cert= 2-clean f-force i-insecure p-provider= 75set -a opts 3-checksum= 4-checksum-type= n-name= 76set -a opts g-global d-dry-run a-all B-box 77argparse -s$opts --$cmd 2> /dev/null 78or return 1 79if set -q argv[ 1 ] 80echo $argv 81return 1 82end 83return 0 84end 85 86function __fish_vagrant_cloud_need_command 87set -l cmd( __fish_vagrant_need_command ) 88test " $cmd [ 1 ] " = cloud2> /dev/null 89or return 1 90set -e cmd[ 1 ] 91 92set -l opts c-check l-logout t-token d-description= s-short-description= p-private b-box-version= 93set -a opts f-force r-release u-url v-version-description= P-page= S-short= o-order= L-limit= 1-sort-by= 94argparse -s$opts --$cmd 2> /dev/null 95or return 1 96if set -q argv[ 1 ] 97echo $argv 98return 1 99end 100return 0 101end 102 103complete -c vagrant -n __fish_vagrant_need_command -fa box -d'Manage boxes: installation, removal, etc.' 104complete -c vagrant -n"__fish_vagrant_using_command box; and __fish_vagrant_box_need_command" -fa" $box_commands " 105complete -c vagrant -n __fish_vagrant_need_command -fa cloud -d'Manage Vagrant Cloud' 106complete -c vagrant -n"__fish_vagrant_using_command cloud; and __fish_vagrant_cloud_need_command" -fa" $cloud_commands " 107complete -c vagrant -n __fish_vagrant_need_command -fa connect 108complete -c vagrant -n __fish_vagrant_need_command -fa destroy -d'Stop and delete all traces of the vagrant machine' 109complete -c vagrant -n __fish_vagrant_need_command -fa docker-exec 110complete -c vagrant -n __fish_vagrant_need_command -fa docker-logs 111complete -c vagrant -n __fish_vagrant_need_command -fa docker-run 112complete -c vagrant -n __fish_vagrant_need_command -fa global-status -d'Show status Vagrant environments for this user' 113complete -c vagrant -n __fish_vagrant_need_command -fa halt -d'Stop a machine' 114complete -c vagrant -n __fish_vagrant_need_command -fa help -d'Show help for a subcommand' 115complete -c vagrant -n __fish_vagrant_need_command -fa init -d'Initialize a new Vagrant env by creating a Vagrantfile' 116complete -c vagrant -n"__fish_vagrant_using_command init" -fa'(__fish_vagrant_boxes)' 117complete -c vagrant -n __fish_vagrant_need_command -fa list-commands 118complete -c vagrant -n __fish_vagrant_need_command -fa login 119complete -c vagrant -n __fish_vagrant_need_command -fa package -d'Package a running vagrant environment into a box' 120complete -c vagrant -n __fish_vagrant_need_command -fa plugin -d'Manages plugins: install, uninstall, update, etc.' 121complete -c vagrant -n __fish_vagrant_need_command -fa provision 122complete -c vagrant -n __fish_vagrant_need_command -fa push 123complete -c vagrant -n __fish_vagrant_need_command -fa rdp 124complete -c vagrant -n __fish_vagrant_need_command -fa reload 125complete -c vagrant -n __fish_vagrant_need_command -fa resume 126complete -c vagrant -n __fish_vagrant_need_command -fa rsync 127complete -c vagrant -n __fish_vagrant_need_command -fa rsync-auto 128complete -c vagrant -n __fish_vagrant_need_command -fa share 129complete -c vagrant -n __fish_vagrant_need_command -fa snapshot 130complete -c vagrant -n __fish_vagrant_need_command -fa ssh -d'Connect to a machine via SSH' 131complete -c vagrant -n __fish_vagrant_need_command -fa ssh-config -d'Print ssh config to connect to machine' 132complete -c vagrant -n __fish_vagrant_need_command -fa status -d'Print status of a machine' 133complete -c vagrant -n __fish_vagrant_need_command -fa suspend -d'Suspend a machine' 134complete -c vagrant -n __fish_vagrant_need_command -fa up -d'Start and provision the environment' 135complete -c vagrant -n"__fish_vagrant_using_command up" -fa'(__fish_vagrant_machines)' 136complete -c vagrant -n __fish_vagrant_need_command -fa version -d'Print current and latest version'