File tree 1 file changed +56
-13
lines changed
1 file changed +56
-13
lines changed Original file line number Diff line number Diff line change 2
2
3
3
_pyang ()
4
4
{
5
- local cur prev words plugin pl_opts wind=1
5
+ local cur prev words plugin hello pl_opts wind=1
6
6
7
7
local formats=" hypertree dsdl depend sample-xml-skeleton omni yin
8
8
tree jstree capability yang xsd uml jtox jsonxsl xmi"
@@ -96,10 +96,56 @@ _pyang()
96
96
COMPREPLY=()
97
97
_get_comp_words_by_ref cur prev cword words
98
98
99
+ while [[ $wind -lt $cword ]]; do
100
+ case ${words[$wind]} in
101
+ -f|--format)
102
+ plugin=${words[$wind+1]}
103
+ ;;
104
+ -L|--hello)
105
+ hello=yes
106
+ ;;
107
+ esac
108
+ (( wind++ ))
109
+ done
110
+
99
111
case $prev in
100
112
-o)
101
- _filedir
102
- return 0
113
+ case $plugin in
114
+ dsdl)
115
+ _filedir ' dsdl'
116
+ ;;
117
+ jsonxsl)
118
+ _filedir ' @(xsl|xslt)'
119
+ ;;
120
+ jstree)
121
+ _filedir ' js'
122
+ ;;
123
+ jtox)
124
+ _filedir ' jtox'
125
+ ;;
126
+ sample-xml-skeleton|hypertree)
127
+ _filedir ' xml'
128
+ ;;
129
+ omni)
130
+ _filedir ' graffle'
131
+ ;;
132
+ uml)
133
+ _filedir ' uml'
134
+ ;;
135
+ xmi)
136
+ _filedir ' xmi'
137
+ ;;
138
+ yang)
139
+ _filedir ' yang'
140
+ ;;
141
+ yin)
142
+ _filedir ' yin'
143
+ ;;
144
+ * )
145
+ _filedir
146
+ ;;
147
+ esac
148
+ return 0
103
149
;;
104
150
-W)
105
151
COMPREPLY=($( compgen -W ' error none' -- " $cur " ) )
@@ -118,19 +164,16 @@ _pyang()
118
164
esac
119
165
120
166
if [[ $cur == -* ]]; then
121
- while [[ $wind -lt $cword ]]; do
122
- if [[ ${words[$wind]} == " -f" || ${words[$wind]} == " --format" ]]
123
- then
124
- plugin=${words[$wind+1]}
125
- pl_opts=" opts_${plugin// -/ _} "
126
- break
127
- fi
128
- done
167
+ pl_opts=" opts_${plugin// -/ _} "
129
168
COMPREPLY=($( compgen -W ' $opts_global ${!pl_opts}' -- " $cur " ) )
130
169
return 0
131
170
fi
132
-
133
- _filedir ' @(yang|yin)'
171
+
172
+ if [[ -z $hello ]]; then
173
+ _filedir ' @(yang|yin)'
174
+ else
175
+ _filedir ' xml'
176
+ fi
134
177
}
135
178
136
179
have pyang && complete -F _pyang pyang
You can’t perform that action at this time.
0 commit comments