Created
February 21, 2017 14:32
-
-
Save wpuricz/578633ac79b5b490df9dc96be6e60036 to your computer and use it in GitHub Desktop.
Auto completion for working with Vapor, includes custom commands for generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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