From 059f01d23a526222926ea96673edb0674549fcdb Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 18 Dec 2021 21:44:17 -0800 Subject: [PATCH] Add new zsh completions --- completions/bun.zsh | 155 +++++++++++++++++++++++++++++++++++++++++- completions/spec.yaml | 116 +++++++++++++++++++++++++++++++ src/cli.zig | 3 +- 3 files changed, 272 insertions(+), 2 deletions(-) diff --git a/completions/bun.zsh b/completions/bun.zsh index bd84a383c4..f3ba77d633 100644 --- a/completions/bun.zsh +++ b/completions/bun.zsh @@ -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 @@ -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) @@ -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) diff --git a/completions/spec.yaml b/completions/spec.yaml index ccab35879c..3a402b7574 100644 --- a/completions/spec.yaml +++ b/completions/spec.yaml @@ -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 diff --git a/src/cli.zig b/src/cli.zig index f876bbf417..5f8d95850d 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -475,6 +475,7 @@ const HelpCommand = struct { "wrangler@beta", "@compiled/react", "@remix-run/dev", + "contentlayer", }; pub fn printWithReason(comptime reason: Reason) void { @@ -491,7 +492,7 @@ const HelpCommand = struct { \\> install Install dependencies for a package.json (bun i) \\> add {s:<16} Add a dependency to package.json (bun a) \\> remove {s:<16} Remove a dependency from package.json (bun rm) - \\> pm More package manager-related subcommands + \\> pm More package manager-related subcommands \\ \\> upgrade Get the latest version of Bun \\> completions Install shell completions for tab-completion