completion/getopt: `shfmt`
parent
8cdd226cf3
commit
9d4b23b992
|
|
@ -1,32 +1,34 @@
|
||||||
__getopt() {
|
# shellcheck shell=bash
|
||||||
local OPTIONS=('-a' '--alternative'
|
|
||||||
'-h' '--help'
|
|
||||||
'-l' '--longoptions'
|
|
||||||
'-n' '--name'
|
|
||||||
'-o' '--options'
|
|
||||||
'-q' '--quiet'
|
|
||||||
'-Q' '--quiet-output'
|
|
||||||
'-s' '--shell'
|
|
||||||
'-T' '--test'
|
|
||||||
'-u' '--unquoted'
|
|
||||||
'-V' '--version')
|
|
||||||
|
|
||||||
local SHELL_ARGS=('sh' 'bash' 'csh' 'tcsh')
|
function _getopt() {
|
||||||
|
local OPTIONS=('-a' '--alternative'
|
||||||
|
'-h' '--help'
|
||||||
|
'-l' '--longoptions'
|
||||||
|
'-n' '--name'
|
||||||
|
'-o' '--options'
|
||||||
|
'-q' '--quiet'
|
||||||
|
'-Q' '--quiet-output'
|
||||||
|
'-s' '--shell'
|
||||||
|
'-T' '--test'
|
||||||
|
'-u' '--unquoted'
|
||||||
|
'-V' '--version')
|
||||||
|
|
||||||
local current=$2
|
local SHELL_ARGS=('sh' 'bash' 'csh' 'tcsh')
|
||||||
local previous=$3
|
|
||||||
|
|
||||||
case $previous in
|
local current=$2
|
||||||
-s|--shell)
|
local previous=$3
|
||||||
readarray -t COMPREPLY < <(compgen -W "${SHELL_ARGS[*]}" -- "$current")
|
|
||||||
;;
|
case $previous in
|
||||||
-n|--name)
|
-s | --shell)
|
||||||
readarray -t COMPREPLY < <(compgen -A function -- "$current")
|
readarray -t COMPREPLY < <(compgen -W "${SHELL_ARGS[*]}" -- "$current")
|
||||||
;;
|
;;
|
||||||
*)
|
-n | --name)
|
||||||
readarray -t COMPREPLY < <(compgen -W "${OPTIONS[*]}" -- "$current")
|
readarray -t COMPREPLY < <(compgen -A function -- "$current")
|
||||||
;;
|
;;
|
||||||
esac
|
*)
|
||||||
|
readarray -t COMPREPLY < <(compgen -W "${OPTIONS[*]}" -- "$current")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
complete -F __getopt getopt
|
complete -F _getopt getopt
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue