-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathremarshal.bash
41 lines (36 loc) · 1.18 KB
/
remarshal.bash
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
_remarshal() {
local cur prev opts formats input_formats output_formats
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD - 1]}
formats='cbor json msgpack toml yaml'
input_formats=$formats
output_formats="$formats python"
opts='--help --version --from --if --input-format --input --indent --stringify --max-values --multiline --output --sort-keys --to --of --output-format --unwrap --verbose --width --wrap --yaml-style'
case "${prev}" in
--from | --if | --input-format | -f)
COMPREPLY=($(compgen -W "${input_formats}" -- ${cur}))
return 0
;;
--to | --of | --output-format | -t)
COMPREPLY=($(compgen -W "${output_formats}" -- ${cur}))
return 0
;;
--yaml-style)
COMPREPLY=($(compgen -W '\" '"\\' '|' '>'" -- ${cur}))
return 0
;;
--input | -i | --output | -o)
COMPREPLY=($(compgen -f -- ${cur}))
return 0
;;
*)
if [[ ${cur} == -* ]]; then
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
else
COMPREPLY=($(compgen -f -- ${cur}))
fi
;;
esac
}
complete -F _remarshal remarshal