@buildinternet/uploads 0.41.0 → 0.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/commands/completion.js +41 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,7 +58,12 @@ answers `did you mean: uploads meta set`. With `--json`, an unknown command
|
|
|
58
58
|
returns `{ "error", "code": "USAGE", "didYouMean" }` on stdout.
|
|
59
59
|
|
|
60
60
|
**Shell completion:** `uploads completion bash|zsh|fish` prints a script to
|
|
61
|
-
stdout.
|
|
61
|
+
stdout. Save it where your shell looks for completions, then start a new shell.
|
|
62
|
+
For zsh, write the script to `~/.zsh/completions/_uploads`, then bind it at the
|
|
63
|
+
end of `~/.zshrc` with `fpath=(~/.zsh/completions $fpath)` and
|
|
64
|
+
`autoload -Uz _uploads && compdef _uploads uploads`. The `compdef` line matters:
|
|
65
|
+
a cached `compinit -C` never rescans fpath, so the file alone can go unnoticed.
|
|
66
|
+
`uploads completion --help` covers the rest.
|
|
62
67
|
|
|
63
68
|
**Globals (before the command):** `--api-url`, `--token`, `--workspace` / `-w`,
|
|
64
69
|
`--env-file`, `--json`, `--quiet`, `--version` / `-V`, `-h` / `--help`, `--all`
|
|
@@ -3,8 +3,9 @@ import { ANNOTATE_FLAGS, COMPLETION_SHELLS, GLOBAL_FLAGS, LIST_LIKE_FLAGS, PUT_L
|
|
|
3
3
|
import { writeCommandHelp } from "../cli-style.js";
|
|
4
4
|
const HELP = `uploads completion <shell>
|
|
5
5
|
|
|
6
|
-
Print a shell completion script to stdout.
|
|
7
|
-
completes commands, subcommands,
|
|
6
|
+
Print a shell completion script to stdout. Save it where your shell looks for
|
|
7
|
+
completions, then start a new shell. Tab then completes commands, subcommands,
|
|
8
|
+
and common flags.
|
|
8
9
|
|
|
9
10
|
Shells:
|
|
10
11
|
bash Bash (complete -F)
|
|
@@ -12,16 +13,36 @@ Shells:
|
|
|
12
13
|
fish Fish (complete -c)
|
|
13
14
|
|
|
14
15
|
Examples:
|
|
15
|
-
#
|
|
16
|
-
uploads completion zsh > ~/.zsh/completions/_uploads
|
|
17
|
-
|
|
18
|
-
# bash
|
|
19
|
-
uploads completion bash > ~/.local/share/bash-completion/completions/uploads
|
|
20
|
-
# or for the current session:
|
|
16
|
+
# bash — for the current session:
|
|
21
17
|
eval "$(uploads completion bash)"
|
|
18
|
+
# or save it:
|
|
19
|
+
uploads completion bash > ~/.local/share/bash-completion/completions/uploads
|
|
22
20
|
|
|
23
21
|
# fish
|
|
24
22
|
uploads completion fish > ~/.config/fish/completions/uploads.fish
|
|
23
|
+
|
|
24
|
+
# zsh — save the script:
|
|
25
|
+
uploads completion zsh > ~/.zsh/completions/_uploads
|
|
26
|
+
# then add these two lines to the END of ~/.zshrc:
|
|
27
|
+
# fpath=(~/.zsh/completions $fpath)
|
|
28
|
+
# autoload -Uz _uploads && compdef _uploads uploads
|
|
29
|
+
|
|
30
|
+
Zsh notes:
|
|
31
|
+
Saving the file into an fpath directory is often not enough. compinit caches
|
|
32
|
+
its scan in ~/.zcompdump, and \`compinit -C\` reuses that cache instead of
|
|
33
|
+
rescanning, so it never sees the new file. Oh My Zsh and several installers
|
|
34
|
+
call compinit that way. Some plugins also rewrite fpath as they load, which
|
|
35
|
+
drops entries added before them; zsh-autocomplete is one.
|
|
36
|
+
|
|
37
|
+
The \`compdef\` line avoids both problems, because it binds the function
|
|
38
|
+
directly instead of relying on a scan. Put it after any framework or plugin
|
|
39
|
+
setup. If completion still does nothing, delete ~/.zcompdump* and start a
|
|
40
|
+
new shell.
|
|
41
|
+
|
|
42
|
+
Check the result with: print $_comps[uploads] — it prints _uploads when the
|
|
43
|
+
completion is active, and nothing when it is not.
|
|
44
|
+
|
|
45
|
+
After you upgrade the CLI, generate the script again so it lists new commands.
|
|
25
46
|
`;
|
|
26
47
|
function bashScript() {
|
|
27
48
|
const cmds = ROOT_COMMANDS.map((c) => c.name).join(" ");
|
|
@@ -140,18 +161,19 @@ function zshScript() {
|
|
|
140
161
|
}).join("\n");
|
|
141
162
|
const globalArgs = GLOBAL_FLAGS.map((g) => {
|
|
142
163
|
const desc = g.summary.replace(/'/g, "'\\''");
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
return ` '(-w --workspace)'{-w,--workspace}'[${desc}]:workspace:'`;
|
|
164
|
+
// Pair each short flag with its long form, keeping the long form's cleaner
|
|
165
|
+
// summary; the short entry then contributes nothing of its own.
|
|
146
166
|
if (g.flag === "--workspace")
|
|
147
|
-
return
|
|
148
|
-
if (g.flag === "-
|
|
149
|
-
return
|
|
167
|
+
return ` '(-w --workspace)'{-w,--workspace}'[${desc}]:workspace:'`;
|
|
168
|
+
if (g.flag === "-w")
|
|
169
|
+
return null; // paired with --workspace
|
|
150
170
|
if (g.flag === "--version")
|
|
171
|
+
return ` '(-V --version)'{-V,--version}'[${desc}]'`;
|
|
172
|
+
if (g.flag === "-V")
|
|
151
173
|
return null;
|
|
152
|
-
if (g.flag === "-h")
|
|
153
|
-
return ` '(-h --help)'{-h,--help}'[${desc}]'`;
|
|
154
174
|
if (g.flag === "--help")
|
|
175
|
+
return ` '(-h --help)'{-h,--help}'[${desc}]'`;
|
|
176
|
+
if (g.flag === "-h")
|
|
155
177
|
return null;
|
|
156
178
|
if (g.flag === "--api-url")
|
|
157
179
|
return ` '--api-url[${desc}]:url:'`;
|
|
@@ -162,7 +184,9 @@ function zshScript() {
|
|
|
162
184
|
return ` '${g.flag}[${desc}]'`;
|
|
163
185
|
})
|
|
164
186
|
.filter(Boolean)
|
|
165
|
-
|
|
187
|
+
// Every spec but the last needs a line continuation — without them zsh ends
|
|
188
|
+
// the `_arguments` call after the first spec and tries to *run* the rest.
|
|
189
|
+
.join(" \\\n");
|
|
166
190
|
const subCases = ROOT_COMMANDS.filter((c) => c.subcommands?.length)
|
|
167
191
|
.map((c) => {
|
|
168
192
|
const lines = c
|