Skip to content

Instantly share code, notes, and snippets.

@dotcypress
Last active November 26, 2022 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dotcypress/585dc1a02f5a40ae9fb65d2900f5ca31 to your computer and use it in GitHub Desktop.
Save dotcypress/585dc1a02f5a40ae9fb65d2900f5ca31 to your computer and use it in GitHub Desktop.
zsh autocomplete plugin for △ now
_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
@dotcypress
Copy link
Author

zsh-now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment