浏览代码

feat(stripe): add completion plugin (#12064)

Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Eric Schultz 3 月之前
父节点
当前提交
d6658f9af3
共有 2 个文件被更改,包括 22 次插入0 次删除
  1. 9 0
      plugins/stripe/README.md
  2. 13 0
      plugins/stripe/stripe.plugin.zsh

+ 9 - 0
plugins/stripe/README.md

@@ -0,0 +1,9 @@
+# Struoe
+
+This plugin provides completion for the [Stripe CLI](https://stripe.com/docs/stripe-cli).
+
+To use it add stripe to the plugins array in your zshrc file.
+
+```bash
+plugins=(... stripe)
+```

+ 13 - 0
plugins/stripe/stripe.plugin.zsh

@@ -0,0 +1,13 @@
+if (( ! $+commands[stripe] )); then
+  return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `stripe`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_stripe" ]]; then
+  typeset -g -A _comps
+  autoload -Uz _stripe
+  _comps[stripe]=_stripe
+fi
+
+stripe completion --shell zsh --write-to-stdout >| "$ZSH_CACHE_DIR/completions/_stripe" &|