-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.fish
75 lines (61 loc) · 2.91 KB
/
generate.fish
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
#! /bin/fish
set -l currentDir $(dirname (status --current-filename))
set -l generatedFilePath $currentDir/conf.d/__fci_plugin_kubectl_fzf_auto_generated.fish
function parseKubectlOptions
set options $argv
set -l outputs
for option in $options
set splits (string split "," $option)
set -l shortOption
set -l longOption
if [ "$splits[2]" != "" ]
set shortOption (string trim (string replace -r '^\s*-' '' $splits[1]))
set longOption $splits[2]
else
set longOption $splits[1]
end
set longOptions (string split "=" "$longOption")
set longOptionName (string trim (string replace -r '^\s*--' '' $longOptions[1]))
set optionValue $longOptions[2]
set -l output
if [ "$shortOption" != "" ]
set output $output "$shortOption/"
end
set output $output "$longOptionName="
if [ "$optionValue" = "false" ]; or [ "$optionValue" = "true" ]
set output $output "?"
end
set outputs $outputs (string join "" $output)
end
set -l i 1
set -l total_count (count $outputs)
for row in $outputs
echo -ne "\t'"
echo -n $row
echo -n "'"
if [ "$i" -lt "$total_count" ]
echo -n " \\"
end
echo
set i (math $i + 1)
end
end
echo '# DO NOT EDIT THIS FILE.
# This file is automatically generated by a script.
' > $generatedFilePath
echo "set -g __fci_plugin_kubectl_fzf_kubectl_global_options \\" >> $generatedFilePath
parseKubectlOptions (kubectl options | grep '^\s*-' | cut -d ':' -f 1) >> $generatedFilePath
echo "set -g __fci_plugin_kubectl_fzf_kubectl_get_options \\" >> $generatedFilePath
parseKubectlOptions (kubectl get --help | grep '^\s*-' | cut -d ':' -f 1) >> $generatedFilePath
echo "set -g __fci_plugin_kubectl_fzf_kubectl_describe_options \\" >> $generatedFilePath
parseKubectlOptions (kubectl describe --help | grep '^\s*-' | cut -d ':' -f 1) >> $generatedFilePath
echo "set -g __fci_plugin_kubectl_fzf_kubectl_delete_options \\" >> $generatedFilePath
parseKubectlOptions (kubectl delete --help | grep '^\s*-' | cut -d ':' -f 1) >> $generatedFilePath
echo "set -g __fci_plugin_kubectl_fzf_kubectl_port_forward_options \\" >> $generatedFilePath
parseKubectlOptions (kubectl port-forward --help | grep '^\s*-' | cut -d ':' -f 1) >> $generatedFilePath
echo "set -g __fci_plugin_kubectl_fzf_kubectl_logs_options \\" >> $generatedFilePath
parseKubectlOptions (kubectl logs --help | grep '^\s*-' | cut -d ':' -f 1) >> $generatedFilePath
echo "set -g __fci_plugin_kubectl_fzf_kubectl_edit_options \\" >> $generatedFilePath
parseKubectlOptions (kubectl edit --help | grep '^\s*-' | cut -d ':' -f 1) >> $generatedFilePath
echo "set -g __fci_plugin_kubectl_fzf_kubectl_exec_options \\" >> $generatedFilePath
parseKubectlOptions (kubectl exec --help | grep '^\s*-' | cut -d ':' -f 1) >> $generatedFilePath