Skip to content
Snippets Groups Projects
Commit aea46f1f authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

reindent bash completion with spaces

parent 70798f22
No related branches found
No related tags found
No related merge requests found
...@@ -2,156 +2,157 @@ ...@@ -2,156 +2,157 @@
# list local repositories # list local repositories
_repo() { _repo() {
COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$(is --no-color repo --no-state --force-offline)" -- "$cur")) COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$(is --no-color repo --no-state --force-offline)" -- "$cur"))
} }
# list all images available in any online repositories # list all images available in any online repositories
_remote_image() { _remote_image() {
COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$(is -q --no-color list --no-sync)" -- "$cur")) COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$(is -q --no-color list --no-sync)" -- "$cur"))
} }
# list all local (files) images # list all local (files) images
_local_image() { _local_image() {
COMPREPLY=("${COMPREPLY[@]}" $(compgen -f -X '!*.isimage' -- "$cur")) COMPREPLY=("${COMPREPLY[@]}" $(compgen -f -X '!*.isimage' -- "$cur"))
} }
# list local and remote images # list local and remote images
_image() { _image() {
_local_image _local_image
_remote_image _remote_image
} }
# generate completion from optional arguments # generate completion from optional arguments
_opt() { _opt() {
COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$*" -- "${cur}")) COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$*" -- "${cur}"))
} }
_is() { _is() {
local cur prev cword local cur prev cword
local -a cmds opts local -a cmds opts
COMPREPLY=() COMPREPLY=()
COMP_WORDBREAKS="${COMP_WORDBREAKS//:}" COMP_WORDBREAKS="${COMP_WORDBREAKS//:}"
_get_comp_words_by_ref cur prev cword _get_comp_words_by_ref cur prev cword
_get_first_arg _get_first_arg
cmds=('add' 'build' 'cat' 'changelog' 'check' 'chroot' 'clean' 'copy' 'del' cmds=('add' 'build' 'cat' 'changelog' 'check' 'chroot' 'clean' 'copy' 'del'
'extract' 'get' 'help' 'info' 'init' 'install' 'list' 'move' 'new' 'repo' 'search' 'version' 'diff') 'extract' 'get' 'help' 'info' 'init' 'install' 'list' 'move' 'new' 'repo'
opts=('-h' '--help' 'search' 'version' 'diff')
'-V' '--version' opts=('-h' '--help'
'-d' '--debug' '-V' '--version'
'-q' '--quiet' '-d' '--debug'
'-R' '--repo-config' '-q' '--quiet'
'-f' '--repo-filter' '-R' '--repo-config'
'-r' '--repo-config' '-f' '--repo-filter'
'-c' '--config' '-r' '--repo-config'
'-C' '--cache' '-c' '--config'
'-t' '--timeout' '-C' '--cache'
'--no-cache' '--no-color') '-t' '--timeout'
'--no-cache' '--no-color')
case "$arg" in case "$arg" in
'') '')
[[ "$cur" == -* ]] && _opt "${opts[@]}" || _opt "${cmds[@]}" [[ "$cur" == -* ]] && _opt "${opts[@]}" || _opt "${cmds[@]}"
;; ;;
add) add)
[[ "$cur" == -* ]] && _opt "-h --help -p --preserve" && return 0 [[ "$cur" == -* ]] && _opt "-h --help -p --preserve" && return 0
_count_args _count_args
(( args == 2 )) && _repo (( args == 2 )) && _repo
(( args > 2 )) && _filedir '?(u)isimage' (( args > 2 )) && _filedir '?(u)isimage'
;; ;;
build) build)
[[ "$cur" == -* ]] && _opt '-h --help -f --force -p --payload -c --no-check' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -f --force -p --payload -c --no-check' && return 0
_count_args _count_args
(( args == 2 )) && _filedir -d (( args == 2 )) && _filedir -d
;; ;;
cat) cat)
[[ "$cur" == -* ]] && _opt '-h --help -b --best' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -b --best' && return 0
_count_args _count_args
(( args == 2 )) && _image (( args == 2 )) && _image
;; ;;
changelog) changelog)
[[ "$cur" == -* ]] && _opt '-h --help -b --best -v --all-version' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -b --best -v --all-version' && return 0
_image _image
;; ;;
check) check)
[[ "$cur" == -* ]] && _opt '-h --help' && return 0 [[ "$cur" == -* ]] && _opt '-h --help' && return 0
_repo _repo
;; ;;
chroot) chroot)
[[ "$cur" == -* ]] && _opt '-h --help -m --no-mount -s --shell' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -m --no-mount -s --shell' && return 0
_filedir -d _filedir -d
;; ;;
clean) clean)
[[ "$cur" == -* ]] && _opt '-h --help' && return 0 [[ "$cur" == -* ]] && _opt '-h --help' && return 0
_repo _repo
;; ;;
copy) copy)
[[ "$cur" == -* ]] && _opt '-h --help -b --best' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -b --best' && return 0
_count_args _count_args
(( args == 2 )) && _remote_image (( args == 2 )) && _remote_image
(( args > 2 )) && _remote_image && _repo (( args > 2 )) && _remote_image && _repo
;; ;;
del) del)
[[ "$cur" == -* ]] && _opt '-h --help -b --best -f --force -p --preserve' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -b --best -f --force -p --preserve' && return 0
_remote_image _remote_image
;; ;;
diff) diff)
[[ "$cur" == -* ]] && _opt '-h --help -b --best' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -b --best' && return 0
_count_args _count_args
(( args < 4 )) && _image (( args < 4 )) && _image
;; ;;
extract) extract)
[[ "$cur" == -* ]] && _opt '-h --help -f --force -b --best -p --payload -g --gen-description' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -f --force -b --best -p --payload -g --gen-description' && return 0
_count_args _count_args
(( args == 2 )) && _image (( args == 2 )) && _image
(( args == 3 )) && _filedir -d (( args == 3 )) && _filedir -d
;; ;;
get) get)
[[ "$cur" == -* ]] && _opt '-h --help -f --force -b --best --payload -I --no-image' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -f --force -b --best --payload -I --no-image' && return 0
_remote_image _remote_image
;; ;;
help) help)
_count_args _count_args
(( args == 2 )) && _opt "${cmds[@]}" (( args == 2 )) && _opt "${cmds[@]}"
;; ;;
info) info)
[[ "$cur" == -* ]] && _opt '-v --verbose -c --changelog -b --best' && return 0 [[ "$cur" == -* ]] && _opt '-v --verbose -c --changelog -b --best' && return 0
_image _image
;; ;;
init) init)
[[ "$cur" == -* ]] && _opt '-h --help' && return 0 [[ "$cur" == -* ]] && _opt '-h --help' && return 0
_filedir -d _filedir -d
;; ;;
install) install)
[[ "$cur" == -* ]] && _opt '-b --best' && return 0 [[ "$cur" == -* ]] && _opt '-b --best' && return 0
_count_args _count_args
(( args == 2 )) && _image (( args == 2 )) && _image
(( args > 2 )) && _filedir (( args > 2 )) && _filedir
;; ;;
list) list)
[[ "$cur" == -* ]] && _opt '-h --help -l --long -j --json -m --md5 -s --size -d --date -a --all-version -A --author -u --url -D --description -S --search --no-sync' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -l --long -j --json -m --md5 -s --size -d --date -a --all-version -A --author -u --url -D --description -S --search --no-sync' && return 0
_remote_image _remote_image
;; ;;
move) move)
[[ "$cur" == -* ]] && _opt '-h --help -b --best -f --force' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -b --best -f --force' && return 0
_remote_image _remote_image
;; ;;
new) new)
[[ "$cur" == -* ]] && _opt '-h --help -f --force' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -f --force' && return 0
_filedir -d _filedir -d
;; ;;
repo) repo)
[[ "$cur" == -* ]] && _opt '-h --help -l --local -r --remote -o --online -O --offline -s --state --force-offline --purge -u --url' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -l --local -r --remote -o --online -O --offline -s --state --force-offline --purge -u --url' && return 0
_repo _repo
;; ;;
search) search)
[[ "$cur" == -* ]] && _opt '-h --help' && return 0 [[ "$cur" == -* ]] && _opt '-h --help' && return 0
;; ;;
version) version)
[[ "$cur" == -* ]] && _opt '-h --help' && return 0 [[ "$cur" == -* ]] && _opt '-h --help' && return 0
;; ;;
esac esac
return 0 return 0
} }
complete -F _is is complete -F _is is
# ex: ts=4 sw=4 et filetype=sh # ex: ts=3 sw=3 et filetype=sh
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment