Last active
November 26, 2022 19:12
-
-
Save dotcypress/585dc1a02f5a40ae9fb65d2900f5ca31 to your computer and use it in GitHub Desktop.
zsh autocomplete plugin for △ now
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_now_commands () | |
{ | |
local curcontext="$curcontext" state line | |
typeset -A opt_args | |
_arguments -C \ | |
":command:->command"\ | |
"*::options:->options" | |
case $state in | |
(command) | |
local -a subcommands | |
subcommands=( | |
"alias:configures aliases for deployments" | |
"deploy:performs a deployment (default)" | |
"domains:manages your domain names" | |
"help:displays complete help for [cmd]" | |
"list:list deployments" | |
"remove:remove a deployment" | |
"secret:configures secrets for deployments" | |
) | |
_describe -t commands "now" subcommands | |
_now_common_flags | |
_arguments \ | |
"-L[configure login]"\ | |
"-v[output the version number]"\ | |
;; | |
(options) | |
case $line[1] in | |
(help) | |
_now_help | |
;; | |
(deploy) | |
_now_common_flags | |
_arguments -C \ | |
"-C[do not attempt to copy URL to clipboard]"\ | |
"-e[include an env var (e.g.: '-e KEY=value'). Can appear many times.]"\ | |
"-f[force a new deployment even if nothing has changed]"\ | |
"-N[forward login information to install private NPM modules]"\ | |
"-p[deployment is public ('/_src' is exposed) (on for oss, off for premium)]"\ | |
;; | |
(domains) | |
_now_domains | |
;; | |
(alias) | |
_now_alias | |
;; | |
(secret) | |
_now_secret | |
;; | |
(list) | |
_now_common_flags | |
;; | |
(remove) | |
_now_common_flags | |
;; | |
esac | |
;; | |
esac | |
} | |
_now_common_flags () | |
{ | |
_arguments -C \ | |
"-c[config file]"\ | |
"-h[output usage information]"\ | |
"-d[debug mode (off)]"\ | |
"-t[token]"\ | |
} | |
_now_alias () | |
{ | |
local curcontext="$curcontext" state line | |
typeset -A opt_args | |
_arguments -C \ | |
":command:->command" | |
case $state in | |
(command) | |
local -a subcommands | |
subcommands=( | |
"ls:lists all your aliases" | |
"rm:remove an alias" | |
"set:adds a new alias" | |
) | |
_describe -t commands "now alias" subcommands | |
_now_common_flags | |
;; | |
esac | |
} | |
_now_secret () | |
{ | |
local curcontext="$curcontext" state line | |
typeset -A opt_args | |
_arguments -C \ | |
":command:->command" | |
case $state in | |
(command) | |
local -a subcommands | |
subcommands=( | |
"ls:lists all your secrets" | |
"rm:remove a secret" | |
"set:adds a new secret" | |
) | |
_describe -t commands "now secret" subcommands | |
_arguments -C \ | |
"-b:treat value as base64-encoded" | |
_now_common_flags | |
;; | |
esac | |
} | |
_now_domains () | |
{ | |
local curcontext="$curcontext" state line | |
typeset -A opt_args | |
_arguments -C \ | |
":command:->command" | |
case $state in | |
(command) | |
local -a subcommands | |
subcommands=( | |
"ls:lists all your domains" | |
"rm:remove a domain" | |
"set:adds a new domain" | |
) | |
_describe -t commands "now domains" subcommands | |
_now_common_flags | |
;; | |
esac | |
} | |
_now_help () | |
{ | |
local curcontext="$curcontext" state line | |
typeset -A opt_args | |
_arguments -C \ | |
":command:->command" | |
case $state in | |
(command) | |
local -a subcommands | |
subcommands=( | |
"alias:alias help" | |
"deploy:deploy help" | |
"domains:domains help" | |
"list:list help" | |
"remove:remove help" | |
"secret:secret help" | |
) | |
_describe -t commands "now help" subcommands | |
;; | |
esac | |
} | |
compdef _now_commands now |
Author
dotcypress
commented
Sep 29, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment