forked from habitat-sh/habitat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_completion.sh
121 lines (115 loc) · 4.06 KB
/
bash_completion.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Copyright:: Copyright (c) 2015-2016 The Habitat Maintainers
#
# The terms of the Evaluation Agreement (Habitat) between Chef Software Inc.
# and the party accessing this file ("Licensee") apply to Licensee's use of
# the Software until such time that the Software is made available under an
# open source license such as the Apache 2.0 License.
# This is a bash completion file for the Habitat `hab` command. It requires
# a "newer" version of bash-completion, so if you see an error such as
# "_get_comp_words_by_ref: command not found", try sourcing the Habitat
# bash-completion package via:
# source "`hab pkg path core/bash-completion`/etc/profile.d/bash_completion.sh"
# bash_completion for hab
_hab()
{
local cur prev
_get_comp_words_by_ref cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
len=${#COMP_WORDS[@]}
if [ $len -gt 2 ]
then
minus2=${COMP_WORDS[COMP_CWORD-2]}
fi
if [ $COMP_CWORD -eq 1 ]; then
case $prev in
hab)
COMPREPLY=( $( compgen -W "apply artifact config file help install origin pkg ring service setup start studio sup user" -- "$cur" ) )
;;
esac
elif [ $COMP_CWORD -eq 2 ]; then
case "$prev" in
artifact)
cmds=( "hash help sign upload verify" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
cli)
cmds=( "help setup" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
config)
cmds=( "apply help" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
file)
cmds=( "help upload" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
origin)
cmds=( "help key" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
pkg)
cmds=( "binlink build exec export help install path" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
ring)
cmds=( "help key" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
service)
cmds=( "help key" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
studio)
cmds=( "build enter help new rm run version" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
sup)
cmds=( "bash config help sh start" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
user)
cmds=( "help key" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
esac
elif [ $COMP_CWORD -eq 3 ]; then
case "$minus2" in
origin)
case "$prev" in
key) #hab origin key
cmds=( "download export generate help import upload" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
esac
;;
ring) # hab ring key
case "$prev" in
key)
cmds=( "export generate help import" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
esac
;;
service) # hab service key
case "$prev" in
key)
cmds=( "generate help" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
esac
;;
user) # hab user key
case "$prev" in
key)
cmds=( "generate help" )
COMPREPLY=( $( compgen -W "$cmds" -- "$cur") )
;;
esac
;;
esac
fi
}
complete -F _hab hab