58 lines
1.8 KiB
Text
58 lines
1.8 KiB
Text
# bash completion for xo-sdlc
|
|
|
|
_xo_sdlc_complete() {
|
|
local cur prev words cword
|
|
_init_completion -n = || return
|
|
|
|
local all_flags=(
|
|
-u --usage -h --help -n --dry-run --all --dirty
|
|
-fj --forgejo
|
|
--list --root -u2 --umbrella2 --sat --satellite
|
|
--repo
|
|
--verify-satellite-list
|
|
--xo-clone --xo-add-fj-remote --xo-push-remote
|
|
--u2-fix-xobuild-subsystem-list --u2-fix-cmake-bootstrap-macros
|
|
--u2-subrepo-status
|
|
--u2-subrepo-clone --u2-push-satellite-remote --u2-pull-satellite-remote
|
|
--xoname=
|
|
)
|
|
|
|
local subsystem_list_file=@CMAKE_INSTALL_FULL_DATADIR@/etc/xo/sdlc/subsystem-list
|
|
|
|
_xo_sdlc_names() {
|
|
cat "${subsystem_list_file}" 2>/dev/null
|
|
}
|
|
|
|
# --xoname=<partial>
|
|
if [[ "${cur}" == --xoname=* ]]; then
|
|
local partial="${cur#--xoname=}"
|
|
COMPREPLY=($(compgen -W "$(_xo_sdlc_names)" -- "${partial}"))
|
|
COMPREPLY=("${COMPREPLY[@]/#/--xoname=}")
|
|
return
|
|
fi
|
|
|
|
# --xoname <partial>
|
|
if [[ "${prev}" == "--xoname" ]]; then
|
|
COMPREPLY=($(compgen -W "$(_xo_sdlc_names)" -- "${cur}"))
|
|
return
|
|
fi
|
|
|
|
# positional xoname after a command that requires one
|
|
if [[ "${cur}" != -* ]]; then
|
|
local w
|
|
for w in "${words[@]}"; do
|
|
case "${w}" in
|
|
--repo|--xo-clone|--xo-add-fj-remote|--xo-push-remote|\
|
|
--u2-fix-cmake-bootstrap-macros|\
|
|
--u2-subrepo-clone|--u2-push-satellite-remote|--u2-pull-satellite-remote)
|
|
COMPREPLY=($(compgen -W "$(_xo_sdlc_names)" -- "${cur}"))
|
|
return
|
|
;;
|
|
esac
|
|
done
|
|
fi
|
|
|
|
COMPREPLY=($(compgen -W "${all_flags[*]}" -- "${cur}"))
|
|
}
|
|
|
|
complete -F _xo_sdlc_complete xo-sdlc
|