Working Saturnin-based meta-command

complete.bash.skel 907B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. __SATURNIN_COMPLETE_CMDNAME=__MKIT_PROJ_PKGNAME__
  3. #shellcheck disable=SC2016
  4. __SATURNIN_COMPLETE_CODETMPL='
  5. __%s() {
  6. local cur opts sopts
  7. COMPREPLY=()
  8. cur="${COMP_WORDS[COMP_CWORD]}"
  9. sopts="-d -h -v"
  10. opts="--help --verbose --debug --version --version-semver"
  11. case "$cur" in
  12. -*)
  13. COMPREPLY=(
  14. $(compgen -W "$sopts $opts" -- "${cur}")
  15. )
  16. ;;
  17. --*)
  18. COMPREPLY=(
  19. $(compgen -W "$opts" -- "${cur}")
  20. )
  21. ;;
  22. *)
  23. COMPREPLY=(
  24. $(compgen -W "$(%s _ls_sc)" "${cur}")
  25. )
  26. esac
  27. }'
  28. eval "$(
  29. #shellcheck disable=SC2059
  30. printf "$__SATURNIN_COMPLETE_CODETMPL" \
  31. $__SATURNIN_COMPLETE_CMDNAME \
  32. $__SATURNIN_COMPLETE_CMDNAME
  33. )"
  34. complete -F "__$__SATURNIN_COMPLETE_CMDNAME" "$__SATURNIN_COMPLETE_CMDNAME"