completion-templates.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.completionZshTemplate = exports.completionShTemplate = void 0;
  4. exports.completionShTemplate = `###-begin-{{app_name}}-completions-###
  5. #
  6. # yargs command completion script
  7. #
  8. # Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
  9. # or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
  10. #
  11. _yargs_completions()
  12. {
  13. local cur_word args type_list
  14. cur_word="\${COMP_WORDS[COMP_CWORD]}"
  15. args=("\${COMP_WORDS[@]}")
  16. # ask yargs to generate completions.
  17. type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
  18. COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
  19. # if no match was found, fall back to filename completion
  20. if [ \${#COMPREPLY[@]} -eq 0 ]; then
  21. COMPREPLY=()
  22. fi
  23. return 0
  24. }
  25. complete -o default -F _yargs_completions {{app_name}}
  26. ###-end-{{app_name}}-completions-###
  27. `;
  28. exports.completionZshTemplate = `###-begin-{{app_name}}-completions-###
  29. #
  30. # yargs command completion script
  31. #
  32. # Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
  33. # or {{app_path}} {{completion_command}} >> ~/.zsh_profile on OSX.
  34. #
  35. _{{app_name}}_yargs_completions()
  36. {
  37. local reply
  38. local si=$IFS
  39. IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
  40. IFS=$si
  41. _describe 'values' reply
  42. }
  43. compdef _{{app_name}}_yargs_completions {{app_name}}
  44. ###-end-{{app_name}}-completions-###
  45. `;