-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
349 additions
and
39 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,281 @@ | ||
# bash completion for eBay's TSV Utility command line tools. | ||
# | ||
# Copyright (c) 2017-2019, eBay Software Foundation | ||
# Initially written by Jon Degenhardt | ||
# | ||
# License: Boost Licence 1.0 (http://boost.org/LICENSE_1_0.txt) | ||
# | ||
# ------------------------------------------------------------- | ||
# | ||
# This file enables option completion for the command line tools. For | ||
# information bash completions and how to install them, see: | ||
# https://github.com/scop/bash-completion | ||
# https://debian-administration.org/article/316/An_introduction_to_bash_completion_part_1 | ||
# | ||
# Mac users may benefit from setup instructions at: | ||
# https://trac.macports.org/wiki/howto/bash-completion | ||
# http://davidalger.com/development/bash-completion-on-os-x-with-brew/ | ||
# | ||
|
||
_csv2tsv() | ||
{ | ||
local cur prev opts | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
opts="--help --help-verbose --version --header --quote --csv-delim --tsv-delim --replacement" | ||
|
||
# Options requiring an argument or precluding other options | ||
case $prev in | ||
-h|--help|--help-verbose|-V|--version|-q|--quote|-c|--csv-delim|-t|--tsv-delim|-r|--replacement) | ||
return | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
} | ||
complete -F _csv2tsv csv2tsv | ||
|
||
_number_lines() | ||
{ | ||
local cur prev opts | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
opts="--help --version --header --header-string --start-number --delimiter" | ||
|
||
# Options requiring an argument or precluding other options | ||
case $prev in | ||
-h|--help|-V|--version|-s|--header-string|-n|--start-number|-d|--delimiter) | ||
return | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
} | ||
complete -F _number_lines number-lines | ||
|
||
_tsv_append() | ||
{ | ||
local cur prev opts | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
opts="--help --help-verbose --version --header --track-source --source-header --file --delimiter" | ||
|
||
# Options requiring an argument or precluding other options | ||
case $prev in | ||
-h|--help|--help-verbose|-V|--version|-s|--source-header|-f|--file|-d|--delimiter) | ||
return | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
} | ||
complete -F _tsv_append tsv-append | ||
|
||
_tsv_filter() | ||
{ | ||
local cur prev opts | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
opts="--help --help-verbose --help-options --version --header --or --invert --delimiter --empty --not-empty --blank --not-blank --is-numeric --is-finite --is-nan --is-infinity --le --lt --ge --gt --eq --ne --str-le --str-lt --str-ge --str-gt --str-eq --istr-eq --str-ne --istr-ne --str-in-fld --istr-in-fld --str-not-in-fld --istr-not-in-fld --regex --iregex --not-regex --not-iregex --ff-le --ff-lt --ff-ge --ff-gt --ff-eq --ff-ne --ff-str-eq --ff-istr-eq --ff-str-ne --ff-istr-ne --ff-absdiff-le --ff-absdiff-gt ff-reldiff-le --ff-reldiff-gt" | ||
|
||
# Options requiring an argument or precluding other options | ||
case $prev in | ||
-h|--help|--help-verbose|--help-options|-V|--version|-d|--delimiter|--le|--lt|--ge|--gt|--eq|--ne|--str-le|--str-lt|--str-ge|--str-gt|--str-eq|--istr-eq|--str-ne|--istr-ne|--str-in-fld|--istr-in-fld|--str-not-in-fld|--istr-not-in-fld|--regex|--iregex|--not-regex|--not-iregex|--ff-le|--ff-lt|--ff-ge|--ff-gt|--ff-eq|--ff-ne|--ff-str-eq|--ff-istr-eq|--ff-str-ne|--ff-istr-ne|--ff-absdiff-le|--ff-absdiff-gt|ff-reldiff-le|--ff-reldiff-gt) | ||
|
||
return | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
} | ||
complete -F _tsv_filter tsv-filter | ||
|
||
_tsv_join() | ||
{ | ||
local cur prev opts | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
opts="--help --help-verbose --version --filter-file --key-fields --data-fields --append-fields --header --prefix --write-all --exclude --delimiter --allow-duplicate-keys" | ||
|
||
# Options requiring an argument or precluding other options | ||
# Options requiring a filename argument are handled in their own case match, ie. -f|--filter-file | ||
case $prev in | ||
-h|--help|--help-verbose|-V|--version|-k|--key-fields|-d|--data-fields|-a|--append-fields|-p|--prefix|-w|--write-all|--delimiter) | ||
return | ||
;; | ||
|
||
-f|--filter-file) | ||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
return 0 | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
} | ||
complete -F _tsv_join tsv-join | ||
|
||
_tsv_pretty() | ||
{ | ||
local cur prev opts | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
opts="--help --help-verbose --version --header --no-header --lookahead --repeat-header --underline-header --format-floats --precision --replace-empty --empty-replacement --delimiter --space-between-fields --max-text-width --auto-preamble --preamble" | ||
|
||
# Options requiring an argument or precluding other options | ||
case $prev in | ||
-h--help|--help-verbose|-V|--version|-l|--lookahead|-r|--repeat-header|-p|--precision|-E|--empty-replacement|-d|--delimiter|-s|--space-between-fields|-m|--max-text-width|-b|--preamble) | ||
return | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
} | ||
complete -F _tsv_pretty tsv-pretty | ||
|
||
_tsv_sample() | ||
{ | ||
local cur prev opts | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
opts="--help --help-verbose --version --header --num --prob --weight-field --key-fields --replace --inorder --print-random --gen-random-inorder --compatibility-mode --static-seed --seed-value --delimiter --prefer-skip-sampling --prefer-algorithm-r" | ||
|
||
# Options requiring an argument or precluding other options | ||
case $prev in | ||
-h|--help|--help-verbose|-V|--version|-n|--num|-p|--prob|-w|--weight-field|-k|--key-fields|-r|--replace|-v|--seed-value|-d|--delimiter|--prefer-skip-sampling|--prefer-algorithm-r) | ||
return | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
} | ||
complete -F _tsv_sample tsv-sample | ||
|
||
_tsv_select() | ||
{ | ||
local cur prev opts | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
opts="--help --version --header --fields --rest --delimiter" | ||
|
||
# Options requiring an argument or precluding other options | ||
# Options with a restricted set of arguments (ie. -r|--rest) have their own case clause. | ||
case $prev in | ||
-h|--help|-V|--version|-f|--fields|-d|--delimiter) | ||
return | ||
;; | ||
-r|--rest) | ||
COMPREPLY=( $(compgen -W "none first last" -- ${cur}) ) | ||
return | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
} | ||
complete -F _tsv_select tsv-select | ||
|
||
_tsv_summarize() | ||
{ | ||
local cur prev opts | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
opts="--help --help-verbose --version --group-by --header --write-header --delimiter --values-delimiter --float-precision --exclude-missing --replace-missing --count --count-header --retain --first --last --min --max --range --sum --mean --median --quantile --mad --var --stdev --mode --mode-count --unique-count --missing-count --not-missing-count --values --unique-values" | ||
|
||
# Options requiring an argument or precluding other options | ||
case $prev in | ||
-h|--help|--help-verbose|-V|--version|-g|--group-by|-d|--delimiter|-v|--values-delimiter|-p|--float-precision|-x|--exclude-missing|-r|--replace-missing|--count-header|--retain|--first|--last|--min|--max|--range|--sum|--mean|--median|--quantile|--mad|--var|--stdev|--mode|--mode-count|--unique-count|--missing-count|--not-missing-count|--values|--unique-values) | ||
return | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
} | ||
complete -F _tsv_summarize tsv-summarize | ||
|
||
_tsv_uniq() | ||
{ | ||
local cur prev opts | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
opts="--help --help-verbose --version --header --fields --ignore-case --repeated --at-least --max --number --equiv --equiv-header --equiv-start --delimiter" | ||
|
||
# Options requiring an argument or precluding other options | ||
case $prev in | ||
-h|--help|--help-verbose|-V|--version|-f|--fields|-a|--at-least|-m|--max|--equiv-header|--equiv-start|-d|--delimiter) | ||
return | ||
;; | ||
esac | ||
|
||
if [[ ${cur} == -* ]] ; then | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
compopt -o filenames | ||
COMPREPLY=( $(compgen -f -X "$xspec" -- ${cur}) $( compgen -d -- "$cur" ) ) | ||
} | ||
complete -F _tsv_uniq tsv-uniq |
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
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
Oops, something went wrong.