_scratch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #compdef scratch
  2. # AUTOMATICALLY GENERATED by `shtab`
  3. _shtab_scratch_commands() {
  4. local _commands=(
  5. "completion:Generate shell completion script"
  6. "create:Create a new scratch instance"
  7. "destroy:Destroy a scratch instance"
  8. "forward:Forward local ports remotely"
  9. "login:Log in to AWS SSO"
  10. "mine:Show active scratch instance"
  11. "push:Push current HEAD (or a specific git commit) to scratch instance"
  12. "sftp:Connect to scratch instance via sftp"
  13. "ssh:Connect to scratch instance via ssh"
  14. )
  15. _describe 'scratch commands' _commands
  16. }
  17. _shtab_scratch_options=(
  18. "(- : *)"{-h,--help}"[show this help message and exit]"
  19. )
  20. _shtab_scratch_completion_options=(
  21. "(- : *)"{-h,--help}"[show this help message and exit]"
  22. ":print shell completion script:(bash zsh tcsh)"
  23. ":print shell completion script:(bash zsh tcsh)"
  24. )
  25. _shtab_scratch_create_options=(
  26. "(- : *)"{-h,--help}"[show this help message and exit]"
  27. "--key-name[Optional EC2 Key Pair name]:key_name:"
  28. "--security-group-name[EC2 Security Group name. Defaults to Materialize scratch account.]:security_group_name:"
  29. "--extra-tags[Additional EC2 tags for created instance. Format\: \{\"key\", \"value\"\}]:extra_tags:"
  30. "--instance-profile[EC2 instance profile \/ IAM role. Defaults to \`admin-instance\`.]:instance_profile:"
  31. "--output-format[]:output_format:(table csv)"
  32. "--git-rev[Git revision of \`materialize\` codebase to push to scratch instance. Defaults to \`HEAD\`]:git_rev:"
  33. "--ssh[ssh into the machine after the launch script is run. Only works if a single instance was started]"
  34. "--max-age-days[Maximum age for scratch instance in days. Defaults to 1.5]:max_age_days:"
  35. ":Use a config from \{machine\}.json in \`misc\/scratch\`. Hint\: \`dev-box\` is a good starter\!:"
  36. )
  37. _shtab_scratch_destroy_options=(
  38. "(- : *)"{-h,--help}"[show this help message and exit]"
  39. "--all-mine[Destroy all of your instances (incompatible with specifying instance IDs)]"
  40. {-y,--yes}"[Don\'t ask for confirmation before destroying]"
  41. "--output-format[]:output_format:(table csv)"
  42. "(*)::Instance IDs to destroy:"
  43. )
  44. _shtab_scratch_forward_options=(
  45. "(- : *)"{-h,--help}"[show this help message and exit]"
  46. ":The ID of the instance to connect to, or \'mine\' to specify your only live instance:"
  47. "(*)::The remote ports to forward locally:"
  48. )
  49. _shtab_scratch_login_options=(
  50. "(- : *)"{-h,--help}"[show this help message and exit]"
  51. )
  52. _shtab_scratch_mine_options=(
  53. "(- : *)"{-h,--help}"[show this help message and exit]"
  54. "--all[Show all instances]"
  55. "--output-format[]:output_format:(table csv)"
  56. "(*)::Whose instances to show (defaults to yourself):"
  57. )
  58. _shtab_scratch_push_options=(
  59. "(- : *)"{-h,--help}"[show this help message and exit]"
  60. "--rev[The git rev to checkout]:rev:"
  61. ":The ID of the instance to connect to, or \'mine\' to specify your only live instance:"
  62. )
  63. _shtab_scratch_sftp_options=(
  64. "(- : *)"{-h,--help}"[show this help message and exit]"
  65. ":The ID of the instance to connect to, or \'mine\' to specify your only live instance:"
  66. )
  67. _shtab_scratch_ssh_options=(
  68. "(- : *)"{-h,--help}"[show this help message and exit]"
  69. ":The ID of the instance to connect to, or \'mine\' to specify your only live instance:"
  70. "(*)::The command to run via SSH, if any:"
  71. )
  72. _shtab_scratch() {
  73. local context state line curcontext="$curcontext" one_or_more='(-)*' remainder='(*)'
  74. if ((${_shtab_scratch_options[(I)${(q)one_or_more}*]} + ${_shtab_scratch_options[(I)${(q)remainder}*]} == 0)); then # noqa: E501
  75. _shtab_scratch_options+=(': :_shtab_scratch_commands' '*::: :->scratch')
  76. fi
  77. _arguments -C -s $_shtab_scratch_options
  78. case $state in
  79. scratch)
  80. words=($line[1] "${words[@]}")
  81. (( CURRENT += 1 ))
  82. curcontext="${curcontext%:*:*}:_shtab_scratch-$line[1]:"
  83. case $line[1] in
  84. completion) _arguments -C -s $_shtab_scratch_completion_options ;;
  85. create) _arguments -C -s $_shtab_scratch_create_options ;;
  86. destroy) _arguments -C -s $_shtab_scratch_destroy_options ;;
  87. forward) _arguments -C -s $_shtab_scratch_forward_options ;;
  88. login) _arguments -C -s $_shtab_scratch_login_options ;;
  89. mine) _arguments -C -s $_shtab_scratch_mine_options ;;
  90. push) _arguments -C -s $_shtab_scratch_push_options ;;
  91. sftp) _arguments -C -s $_shtab_scratch_sftp_options ;;
  92. ssh) _arguments -C -s $_shtab_scratch_ssh_options ;;
  93. esac
  94. esac
  95. }
  96. typeset -A opt_args
  97. if [[ $zsh_eval_context[-1] == eval ]]; then
  98. # eval/source/. command, register function for later
  99. compdef _shtab_scratch -N scratch
  100. else
  101. # autoload from fpath, call function directly
  102. _shtab_scratch "$@"
  103. fi