-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(completions): add Bash and fish
These completions only apply to the command `remarshal`, not `foo2bar` short commands.
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#! /usr/bin/env fish | ||
|
||
cd "$(path dirname "$(status filename)")" | ||
|
||
set --local src remarshal.fish | ||
set --local dst $__fish_config_dir/completions/ | ||
|
||
printf 'copying "%s" to "%s"\n' $src $dst | ||
|
||
cp $src $dst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 --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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
complete -c remarshal -s h -l help -d "Show help message and exit" | ||
complete -c remarshal -s v -l version -d "Show program's version number and exit" | ||
|
||
complete -c remarshal -s f -l from -l if -l input-format -x -a "cbor json msgpack toml yaml" -d "Input format" | ||
|
||
complete -c remarshal -s i -l input -r -d "Input file" | ||
complete -c remarshal -s o -l output -r -d "Output file" | ||
|
||
complete -c remarshal -s t -l to -l of -l output-format -x -a "cbor json msgpack python toml yaml" -d "Output format" | ||
|
||
complete -c remarshal -l indent -x -d "JSON and YAML indentation" | ||
complete -c remarshal -s k -l stringify -d "Turn special values into strings" | ||
complete -c remarshal -l max-values -x -d "Maximum number of values in input data" | ||
complete -c remarshal -s s -l sort-keys -d "Sort JSON, Python, and TOML keys" | ||
complete -c remarshal -l width -x -d "Python and YAML line width" | ||
complete -c remarshal -l yaml-style -x -a '"\'" "\\"" "|" ">"' -d "YAML formatting style" | ||
|
||
complete -c remarshal -l unwrap -x -d "Only output data under given key" | ||
complete -c remarshal -l verbose -d "Print debug information on error" | ||
complete -c remarshal -l wrap -x -d "Wrap data in a map with given key" |