-
Notifications
You must be signed in to change notification settings - Fork 0
/
helm.elv
32 lines (28 loc) · 904 Bytes
/
helm.elv
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
use str
use path
var rc_dir = (path:dir (src)[name])
fn helm_completion {|@cmd|
if (eq $cmd []) {
return
}
# The fix allowing to use aliases with this function
# It will be always helm
set cmd[0] = helm
var completions = [(bash --norc --noprofile $rc_dir/adapter_helm.sh $rc_dir (- (count $cmd) 1) $@cmd | from-lines | each {|n| str:trim-space $n} )]
var prefix = $cmd[-1]
if (eq $prefix '') {
put $@completions
} else {
if (not-eq $@completions []) {
if (eq [] (each {|n| if (str:has-prefix $n $prefix) { put $n }} $completions)) {
# no shared prefix
# for example kubectl --namespace= will return list of namespaces
# we should add --namespace= prefix to each completion
each {|n| put $prefix$n} $completions
} else {
put $@completions
}
}
}
}
set edit:completion:arg-completer[helm] = $helm_completion~