Last active
June 1, 2020 22:12
-
-
Save lancewf/0af1a4d8e7bb6904e8f7f203eb2a3bcd to your computer and use it in GitHub Desktop.
Automate completion for Habitat.sh CLI
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
#!/bin/bash | |
_hab_completions() | |
{ | |
local opts prev cur | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
case $COMP_CWORD in | |
1) | |
COMPREPLY=( $(compgen -W "pkg config origin bldr cli file help license plan ring studio sup supportbundle svc user" -- "${cur}") ) | |
;; | |
2) | |
case "$prev" in | |
config) | |
COMPREPLY=( $(compgen -W "apply show help" -- "${cur}") ) | |
;; | |
pkg) | |
COMPREPLY=( $(compgen -W "download env exec export has help info install list path promote provides search sign uninstall upload verify" -- "${cur}") ) | |
;; | |
svc) | |
COMPREPLY=( $(compgen -W "help key load start status stop unload" -- "${cur}") ) | |
;; | |
sup) | |
COMPREPLY=( $(compgen -W "help bash depart run secret sh status term" -- "${cur}") ) | |
;; | |
esac | |
;; | |
*) | |
COMPREPLY=( $(compgen -f -- "${cur}") ) | |
compopt -o nospace | |
;; | |
esac | |
return 0 | |
} | |
complete -F _hab_completions hab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment