Skip to content

Commit

Permalink
Add new zsh completions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Dec 19, 2021
1 parent 5f80f9c commit 059f01d
Show file tree
Hide file tree
Showing 3 changed files with 272 additions and 2 deletions.
155 changes: 154 additions & 1 deletion completions/bun.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,51 @@ _bun() {
IFS=$'\n' scripts_list=($(SHELL=zsh bun getcompletes i))
compadd $scripts_list && ret=0

main_commands=('bun:"Generate a bundle" create:"Create a new project" dev:"Start a dev server" help:"Show command help" run:"Run a script or package bin" upgrade:"Upgrade to the latest version of Bun"')
main_commands=('add\:"Add a dependency to package.json" bun\:"Generate a bundle" create\:"Create a new project" dev\:"Start a dev server" help\:"Show command help" install\:"Install packages from package.json" remove\:"Remove a dependency from package.json" run\:"Run a script or package bin" upgrade\:"Upgrade to the latest version of Bun"')
main_commands=($main_commands)
_alternative "args:Bun:(($main_commands))"
;;
args)
case $line[1] in
add)

# ---- Command: add
_arguments -s -C \
'1: :->cmd1' \
'*: :->package' \
'--version[Show version and exit]' \
'-V[Show version and exit]' \
'--cwd[Change directory]:cwd' \
'--help[Show command help]' \
'-h[Show command help]' \
'--registry[Change default registry (default: \$BUN_CONFIG_REGISTRY || \$npm_config_registry)]:registry' \
'--token[Authentication token used for npm registry requests (default: \$npm_config_token)]:token' \
'-y[Write a yarn.lock file (yarn v1)]' \
'--yarn[Write a yarn.lock file (yarn v1)]' \
'--production[Don'"'"'t install devDependencies]' \
'--optional[Add dependency to optionalDependencies]' \
'--development[Add dependency to devDependencies]' \
'-d[Add dependency to devDependencies]' \
'-p[Don'"'"'t install devDependencies]' \
'--no-save[]' \
'--dry-run[Don'"'"'t install anything]' \
'--force[Always request the latest versions from the registry & reinstall all dependenices]' \
'--lockfile[Store & load a lockfile at a specific filepath]:lockfile' \
'--cache-dir[Store & load cached data from a specific directory path]:cache-dir' \
'--no-cache[Ignore manifest cache entirely]' \
'--silent[Don'"'"'t output anything]' \
'--verbose[Excessively verbose logging]' \
'--cwd[Set a specific cwd]:cwd' \
'--backend[Platform-specific optimizations for installing dependencies]:backend:("clonefile" "copyfile" "hardlink" "clonefile_each_dir")' \
'--link-native-bins[Link "bin" from a matching platform-specific dependency instead. Default: esbuild, turbo]:link-native-bins' &&
ret=0

case $state in
package) ;;

esac

;;
bun)

# ---- Command: bun
Expand Down Expand Up @@ -164,6 +203,53 @@ _bun() {
ret=0

;;
install)

# ---- Command: help install
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'--version[Show version and exit]' \
'-V[Show version and exit]' \
'--cwd[Change directory]:cwd' \
'--help[Show command help]' \
'-h[Show command help]' \
'--all[]' &&
ret=0

;;

remove)

# ---- Command: help remove
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'--version[Show version and exit]' \
'-V[Show version and exit]' \
'--cwd[Change directory]:cwd' \
'--help[Show command help]' \
'-h[Show command help]' \
'--all[]' &&
ret=0

;;

run)

# ---- Command: help run
_arguments -s -C \
'1: :->cmd1' \
'2: :->cmd2' \
'--version[Show version and exit]' \
'-V[Show version and exit]' \
'--cwd[Change directory]:cwd' \
'--help[Show command help]' \
'-h[Show command help]' \
'--all[]' &&
ret=0

;;

create)

Expand Down Expand Up @@ -275,6 +361,73 @@ _bun() {
;;

esac
;;
install)

# ---- Command: install
_arguments -s -C \
'1: :->cmd1' \
'--version[Show version and exit]' \
'-V[Show version and exit]' \
'--cwd[Change directory]:cwd' \
'--help[Show command help]' \
'-h[Show command help]' \
'--registry[Change default registry (default: \$BUN_CONFIG_REGISTRY || \$npm_config_registry)]:registry' \
'--token[Authentication token used for npm registry requests (default: \$npm_config_token)]:token' \
'-y[Write a yarn.lock file (yarn v1)]' \
'--yarn[Write a yarn.lock file (yarn v1)]' \
'--production[Don'"'"'t install devDependencies]' \
'-p[Don'"'"'t install devDependencies]' \
'--no-save[]' \
'--dry-run[Don'"'"'t install anything]' \
'--force[Always request the latest versions from the registry & reinstall all dependenices]' \
'--lockfile[Store & load a lockfile at a specific filepath]:lockfile' \
'--cache-dir[Store & load cached data from a specific directory path]:cache-dir' \
'--no-cache[Ignore manifest cache entirely]' \
'--silent[Don'"'"'t output anything]' \
'--verbose[Excessively verbose logging]' \
'--cwd[Set a specific cwd]:cwd' \
'--backend[Platform-specific optimizations for installing dependencies]:backend:("clonefile" "copyfile" "hardlink" "clonefile_each_dir")' \
'--link-native-bins[Link "bin" from a matching platform-specific dependency instead. Default: esbuild, turbo]:link-native-bins' &&
ret=0

;;

remove)

# ---- Command: remove
_arguments -s -C \
'1: :->cmd1' \
'*: :->package' \
'--version[Show version and exit]' \
'-V[Show version and exit]' \
'--cwd[Change directory]:cwd' \
'--help[Show command help]' \
'-h[Show command help]' \
'--registry[Change default registry (default: \$BUN_CONFIG_REGISTRY || \$npm_config_registry)]:registry' \
'--token[Authentication token used for npm registry requests (default: \$npm_config_token)]:token' \
'-y[Write a yarn.lock file (yarn v1)]' \
'--yarn[Write a yarn.lock file (yarn v1)]' \
'--production[Don'"'"'t install devDependencies]' \
'-p[Don'"'"'t install devDependencies]' \
'--no-save[]' \
'--dry-run[Don'"'"'t install anything]' \
'--force[Always request the latest versions from the registry & reinstall all dependenices]' \
'--lockfile[Store & load a lockfile at a specific filepath]:lockfile' \
'--cache-dir[Store & load cached data from a specific directory path]:cache-dir' \
'--no-cache[Ignore manifest cache entirely]' \
'--silent[Don'"'"'t output anything]' \
'--verbose[Excessively verbose logging]' \
'--cwd[Set a specific cwd]:cwd' \
'--backend[Platform-specific optimizations for installing dependencies]:backend:("clonefile" "copyfile" "hardlink" "clonefile_each_dir")' \
'--link-native-bins[Link "bin" from a matching platform-specific dependency instead. Default: esbuild, turbo]:link-native-bins' &&
ret=0

case $state in
package) ;;

esac

;;
run)

Expand Down
116 changes: 116 additions & 0 deletions completions/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,122 @@ subcommands:
- &port name: port
type: int
summary: Port number
install:
summary: Install packages from package.json
options:
- name: registry
type: string
summary: "Change default registry (default: $BUN_CONFIG_REGISTRY || $npm_config_registry)"
- name: token
type: string
summary: "Authentication token used for npm registry requests (default: $npm_config_token)"
- y -- "Write a yarn.lock file (yarn v1)"
- yarn -- "Write a yarn.lock file (yarn v1)"
- production -- "Don't install devDependencies"
- p -- "Don't install devDependencies"
- no-save --
- dry-run -- "Don't install anything"
- force -- "Always request the latest versions from the registry & reinstall all dependenices"
- name: lockfile
type: string
summary: "Store & load a lockfile at a specific filepath"
- name: cache-dir
type: string
summary: "Store & load cached data from a specific directory path"
- no-cache -- "Ignore manifest cache entirely"
- silent -- "Don't output anything"
- verbose -- "Excessively verbose logging"
- name: cwd
type: string
summary: "Set a specific cwd"
- name: backend
summary: "Platform-specific optimizations for installing dependencies"
type: string
enum: ["clonefile", "copyfile", "hardlink", "clonefile_each_dir"]
- name: link-native-bins
summary: 'Link "bin" from a matching platform-specific dependency instead. Default: esbuild, turbo'
add:
summary: Add a dependency to package.json
options:
- name: registry
type: string
summary: "Change default registry (default: $BUN_CONFIG_REGISTRY || $npm_config_registry)"
- name: token
type: string
summary: "Authentication token used for npm registry requests (default: $npm_config_token)"
- y -- "Write a yarn.lock file (yarn v1)"
- yarn -- "Write a yarn.lock file (yarn v1)"
- production -- "Don't install devDependencies"
- optional -- "Add dependency to optionalDependencies"
- development -- "Add dependency to devDependencies"
- d -- "Add dependency to devDependencies"

- p -- "Don't install devDependencies"
- no-save --
- dry-run -- "Don't install anything"
- force -- "Always request the latest versions from the registry & reinstall all dependenices"
- name: lockfile
type: string
summary: "Store & load a lockfile at a specific filepath"
- name: cache-dir
type: string
summary: "Store & load cached data from a specific directory path"
- no-cache -- "Ignore manifest cache entirely"
- silent -- "Don't output anything"
- verbose -- "Excessively verbose logging"
- name: cwd
type: string
summary: "Set a specific cwd"
- name: backend
summary: "Platform-specific optimizations for installing dependencies"
type: string
enum: ["clonefile", "copyfile", "hardlink", "clonefile_each_dir"]
- name: link-native-bins
summary: 'Link "bin" from a matching platform-specific dependency instead. Default: esbuild, turbo'
parameters:
- name: package
multiple: true
type: string
required: true
remove:
summary: Remove a dependency from package.json
options:
- name: registry
type: string
summary: "Change default registry (default: $BUN_CONFIG_REGISTRY || $npm_config_registry)"
- name: token
type: string
summary: "Authentication token used for npm registry requests (default: $npm_config_token)"
- y -- "Write a yarn.lock file (yarn v1)"
- yarn -- "Write a yarn.lock file (yarn v1)"
- production -- "Don't install devDependencies"
- p -- "Don't install devDependencies"
- no-save --
- dry-run -- "Don't install anything"
- force -- "Always request the latest versions from the registry & reinstall all dependenices"
- name: lockfile
type: string
summary: "Store & load a lockfile at a specific filepath"
- name: cache-dir
type: string
summary: "Store & load cached data from a specific directory path"
- no-cache -- "Ignore manifest cache entirely"
- silent -- "Don't output anything"
- verbose -- "Excessively verbose logging"
- name: cwd
type: string
summary: "Set a specific cwd"
- name: backend
summary: "Platform-specific optimizations for installing dependencies"
type: string
enum: ["clonefile", "copyfile", "hardlink", "clonefile_each_dir"]
- name: link-native-bins
summary: 'Link "bin" from a matching platform-specific dependency instead. Default: esbuild, turbo'
parameters:
- name: package
multiple: true
type: string
required: true

parameters:
- name: sasdasdds
Expand Down
3 changes: 2 additions & 1 deletion src/cli.zig
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ const HelpCommand = struct {
"wrangler@beta",
"@compiled/react",
"@remix-run/dev",
"contentlayer",
};

pub fn printWithReason(comptime reason: Reason) void {
Expand All @@ -491,7 +492,7 @@ const HelpCommand = struct {
\\> <r> <b><green>install<r> Install dependencies for a package.json <d>(bun i)<r>
\\> <r> <b><blue>add <r><d> {s:<16}<r> Add a dependency to package.json <d>(bun a)<r>
\\> <r> remove <r><d> {s:<16}<r> Remove a dependency from package.json <d>(bun rm)<r>
\\> <r> pm <r> More package manager-related subcommands
\\> <r> pm <r> More package manager-related subcommands
\\
\\> <r> <b><blue>upgrade <r> Get the latest version of Bun
\\> <r> <b><d>completions<r> Install shell completions for tab-completion
Expand Down

0 comments on commit 059f01d

Please sign in to comment.