Skip to content

Instantly share code, notes, and snippets.

@jessenich
Last active April 18, 2021 08:43
Show Gist options
  • Select an option

  • Save jessenich/6228c8c6da8b2bc55a1fde8d88071103 to your computer and use it in GitHub Desktop.

Select an option

Save jessenich/6228c8c6da8b2bc55a1fde8d88071103 to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
###
# Provides completion assistance for openapi-generator-cli
# Install
# Mac:
# brew install bash-completion
# cp openapi-generator-cli-completion.bash `brew --prefix`/etc/bash_completion.d
# Linux: many distributions include this automatically. Search for your distro-specific instructions.
# When in doubt, try sourcing this file:
# type complete && source openapi-generator-cli
#
# see http://tldp.org/LDP/abs/html/tabexpansion.html
###
_openapi_generator_cli_completions() {
COMPREPLY=()
local IFS=$' \t\n'
local options=()
options+=("$($1 completion ${COMP_WORDS[@]:1})")
case "${COMP_WORDS[1]}" in
generate)
case "${COMP_WORDS[@]:2}" in
-l|--lang|-g|--generator-name)
;;
esac
;;
*)
# ignore
;;
esac
# printf '%s\n' "${options[@]}"
if [[ -n "${options[@]}" ]]; then
COMPREPLY=( $(compgen -W "${options}" -- ${2}) )
fi
}
for i in openapi-generator-cli openapi-generator; do
type $i > /dev/null 2>&1 && complete -F _openapi_generator_cli_completions $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment