Skip to content

Instantly share code, notes, and snippets.

@lancewf
Last active June 1, 2020 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lancewf/0af1a4d8e7bb6904e8f7f203eb2a3bcd to your computer and use it in GitHub Desktop.
Save lancewf/0af1a4d8e7bb6904e8f7f203eb2a3bcd to your computer and use it in GitHub Desktop.
Automate completion for Habitat.sh CLI
#!/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