Skip to content

Instantly share code, notes, and snippets.

@wpuricz
Created February 21, 2017 14:32
Show Gist options
  • Save wpuricz/578633ac79b5b490df9dc96be6e60036 to your computer and use it in GitHub Desktop.
Save wpuricz/578633ac79b5b490df9dc96be6e60036 to your computer and use it in GitHub Desktop.
Auto completion for working with Vapor, includes custom commands for generator
# Vapor Autocomplete
_vapor_completion() {
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
local vaporCommands=$(vapor --help | grep 'Usage:' | sed -E 's/^[^<]*<([^>]*)>/\1/' | tr '|' '\n' 2>/dev/null)
local genCommands="generate migration controller model resource"
case "${prev}" in
run)
local runCommands=$(vapor run some-command-that-does-not-exist | grep 'Usage:' | sed -E 's/^[^<]*<([^>]*)>/\1/' | tr '|' '\n' 2>/dev/null)
COMPREPLY=( $(compgen -W "${runCommands}" -- ${cur}) )
return 0
;;
*)
;;
esac
COMPREPLY=( $(compgen -W "${vaporCommands}" -- ${cur}) )
COMPREPLY=( $(compgen -W "${genCommands}" -- ${cur}) )
return 0
}
complete -F _vapor_completion vt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment