usage-cli 3.5.2

CLI for working with usage-based CLIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
.TH USAGE-CLI 1
.SH NAME
usage\-cli \- CLI for working with usage\-based CLIs
.SH SYNOPSIS
\fBusage\fR [OPTIONS] [<COMPLETIONS>] [COMMAND]
.SH DESCRIPTION
CLI for working with usage\-based CLIs
.PP
.SH OPTIONS
.TP
\fB\-\-usage\-spec\fR
Outputs a `usage.kdl` spec for this CLI itself
.SH ARGUMENTS
.TP
\fB<COMPLETIONS>\fR
Outputs completions for the specified shell for completing the `usage` CLI itself
.SH COMMANDS
.TP
\fBbash\fR
Execute a shell script with the specified shell
.TP
\fBcomplete\-word\fR
Generate shell completion candidates for a partial command line
.RS
\fIAliases: \fRcw
.RE
.TP
\fBexec\fR
Execute a script, parsing args and exposing them as environment variables
.RS
\fIAliases: \fRx
.RE
.TP
\fBfish\fR
Execute a shell script with the specified shell
.TP
\fBgenerate\fR
Generate completions, documentation, and other artifacts from usage specs
.RS
\fIAliases: \fRg
.RE
.TP
\fBgenerate completion\fR
Generate shell completion scripts for bash, fish, nu, powershell, or zsh
.RS
\fIAliases: \fRc
.RE
.TP
\fBgenerate completion\-init\fR
Generate a shell init script that auto\-completes any usage shebang script on $PATH
.RS
\fIAliases: \fRci
.RE
.TP
\fBgenerate fig\fR
Generate Fig completion spec for Amazon Q / Fig
.TP
\fBgenerate json\fR
Outputs a usage spec in json format
.TP
\fBgenerate manpage\fR
.RS
\fIAliases: \fRman
.RE
.TP
\fBgenerate markdown\fR
Generate markdown documentation from usage specs
.RS
\fIAliases: \fRmd
.RE
.TP
\fBgenerate sdk\fR
Generate a type\-safe SDK from a usage spec
.TP
\fBlint\fR
Lint a usage spec file for common issues
.TP
\fBpowershell\fR
Execute a shell script with the specified shell
.TP
\fBsponsors\fR
Show the companies sponsoring usage and the en.dev project family
.TP
\fBzsh\fR
Execute a shell script with the specified shell
.SH "USAGE BASH"
Execute a shell script with the specified shell

Typically, this will be called by a script's shebang.

If using `var=#true` on args/flags, they will be joined with spaces using `shell_words::join()`
to properly escape and quote values with spaces in them.
.PP
\fBUsage:\fR usage bash [OPTIONS] <SCRIPT> [<ARGS>] ...
.PP
\fBOptions:\fR
.PP
.TP
\fB\-h\fR
Show help
.TP
\fB\-\-help\fR
Show help
\fBArguments:\fR
.PP
.TP
\fB<ARGS>\fR
Arguments to pass to script
.SH "USAGE COMPLETE-WORD"
Generate shell completion candidates for a partial command line

This is used internally by shell completion scripts to provide intelligent completions for commands, flags, and arguments.
.PP
\fBUsage:\fR usage complete\-word [OPTIONS] [<WORDS>] ...
.PP
\fBOptions:\fR
.PP
.TP
\fB\-f, \-\-file\fR \fI<FILE>\fR
Usage spec file or script with usage shebang, use "\-" to read from stdin
.TP
\fB\-s, \-\-spec\fR \fI<SPEC>\fR
Raw string spec input
.TP
\fB\-\-cword\fR \fI<CWORD>\fR
Current word index
.TP
\fB\-\-shell\fR \fI<SHELL>\fR
.RS
\fIDefault: \fRbash
.RE
\fBArguments:\fR
.PP
.TP
\fB<WORDS>\fR
User's input from the command line
.SH "USAGE EXEC"
Execute a script, parsing args and exposing them as environment variables
.PP
\fBUsage:\fR usage exec [OPTIONS] <COMMAND> <BIN> [<ARGS>] ...
.PP
\fBOptions:\fR
.PP
.TP
\fB\-h\fR
Show help
.TP
\fB\-\-help\fR
Show help
\fBArguments:\fR
.PP
.TP
\fB<COMMAND>\fR
command to execute after parsing usage spec
.TP
\fB<BIN>\fR
path to script to execute
.TP
\fB<ARGS>\fR
arguments to pass to script
.SH "USAGE FISH"
Execute a shell script with the specified shell

Typically, this will be called by a script's shebang.

If using `var=#true` on args/flags, they will be joined with spaces using `shell_words::join()`
to properly escape and quote values with spaces in them.
.PP
\fBUsage:\fR usage fish [OPTIONS] <SCRIPT> [<ARGS>] ...
.PP
\fBOptions:\fR
.PP
.TP
\fB\-h\fR
Show help
.TP
\fB\-\-help\fR
Show help
\fBArguments:\fR
.PP
.TP
\fB<ARGS>\fR
Arguments to pass to script
.SH "USAGE GENERATE COMPLETION"
Generate shell completion scripts for bash, fish, nu, powershell, or zsh
.PP
\fBUsage:\fR usage generate completion [OPTIONS] <SHELL> <BIN>
.PP
\fBOptions:\fR
.PP
.TP
\fB\-f, \-\-file\fR \fI<FILE>\fR
A .usage.kdl spec file to use for generating completions, use "\-" to read from stdin
.TP
\fB\-\-cache\-key\fR \fI<CACHE_KEY>\fR
A cache key to use for storing the results of calling the CLI with \-\-usage\-cmd
.TP
\fB\-\-include\-bash\-completion\-lib\fR
Include https://github.com/scop/bash\-completion

This is required for usage completions to work in bash, but the user may already provide it
.TP
\fB\-\-usage\-bin\fR \fI<USAGE_BIN>\fR
Override the bin used for calling back to usage\-cli

You may need to set this if you have a different bin named "usage"
.RS
\fIDefault: \fRusage
.RE
.TP
\fB\-\-usage\-cmd\fR \fI<USAGE_CMD>\fR
A command which generates a usage spec e.g.: `mycli \-\-usage` or `mycli completion usage` Defaults to "$bin \-\-usage"
\fBArguments:\fR
.PP
.TP
\fB<SHELL>\fR
Shell to generate completions for
.TP
\fB<BIN>\fR
The CLI which we're generating completions for
.SH "USAGE GENERATE COMPLETION-INIT"
Generate a shell init script that auto\-completes any usage shebang script on $PATH

Source the output once from your shell rc (e.g. ~/.bashrc) to enable tab\-completion for any executable whose first line is a `usage` shebang — no per\-script `usage g completion` step required.
.PP
\fBUsage:\fR usage generate completion\-init [OPTIONS] <SHELL>
.PP
\fBOptions:\fR
.PP
.TP
\fB\-\-usage\-bin\fR \fI<USAGE_BIN>\fR
Override the bin used for calling back to usage\-cli

You may need to set this if you have a different bin named "usage"
.RS
\fIDefault: \fRusage
.RE
\fBArguments:\fR
.PP
.TP
\fB<SHELL>\fR
Shell to generate the init script for
.SH "USAGE GENERATE FIG"
Generate Fig completion spec for Amazon Q / Fig
.PP
\fBUsage:\fR usage generate fig [OPTIONS]
.PP
\fBOptions:\fR
.PP
.TP
\fB\-f, \-\-file\fR \fI<FILE>\fR
A usage spec taken in as a file, use "\-" to read from stdin
.TP
\fB\-\-out\-file\fR \fI<OUT_FILE>\fR
File path where the generated Fig spec will be saved
.TP
\fB\-\-spec\fR \fI<SPEC>\fR
Raw string spec input
.SH "USAGE GENERATE JSON"
Outputs a usage spec in json format
.PP
\fBUsage:\fR usage generate json [OPTIONS]
.PP
\fBOptions:\fR
.PP
.TP
\fB\-f, \-\-file\fR \fI<FILE>\fR
A usage spec taken in as a file, use "\-" to read from stdin
.TP
\fB\-\-spec\fR \fI<SPEC>\fR
raw string spec input
.SH "USAGE GENERATE MANPAGE"
\fBUsage:\fR usage generate manpage [OPTIONS]
.PP
\fBOptions:\fR
.PP
.TP
\fB\-f, \-\-file\fR \fI<FILE>\fR
A usage spec taken in as a file, use "\-" to read from stdin
.TP
\fB\-o, \-\-out\-file\fR \fI<OUT_FILE>\fR
Output file path (defaults to stdout)
.TP
\fB\-s, \-\-section\fR \fI<SECTION>\fR
Manual section number (default: 1)

Common sections: \- 1: User commands \- 5: File formats \- 7: Miscellaneous \- 8: System administration commands
.RS
\fIDefault: \fR1
.RE
.SH "USAGE GENERATE MARKDOWN"
Generate markdown documentation from usage specs
.PP
\fBUsage:\fR usage generate markdown [OPTIONS]
.PP
\fBOptions:\fR
.PP
.TP
\fB\-f, \-\-file\fR \fI<FILE>\fR
A usage spec taken in as a file, use "\-" to read from stdin
.TP
\fB\-m, \-\-multi\fR
Render each subcommand as a separate markdown file
.TP
\fB\-\-html\-encode\fR
Escape HTML in markdown
.TP
\fB\-\-out\-dir\fR \fI<OUT_DIR>\fR
Output markdown files to this directory (required when using \-\-multi)
.TP
\fB\-\-out\-file\fR \fI<OUT_FILE>\fR
Output file path for single\-file markdown generation
.TP
\fB\-\-replace\-pre\-with\-code\-fences\fR
Replace `<pre>` tags with markdown code fences
.TP
\fB\-\-url\-prefix\fR \fI<URL_PREFIX>\fR
Prefix to add to all URLs
.SH "USAGE GENERATE SDK"
Generate a type\-safe SDK from a usage spec
.PP
\fBUsage:\fR usage generate sdk [OPTIONS]
.PP
\fBOptions:\fR
.PP
.TP
\fB\-f, \-\-file\fR \fI<FILE>\fR
A usage spec taken in as a file
.TP
\fB\-l, \-\-language\fR \fI<LANGUAGE>\fR
Target language for the SDK
.TP
\fB\-o, \-\-output\fR \fI<OUTPUT>\fR
Output directory for generated SDK files
.TP
\fB\-p, \-\-package\-name\fR \fI<PACKAGE_NAME>\fR
Override the package/module name (defaults to spec bin name)
.TP
\fB\-\-spec\fR \fI<SPEC>\fR
Raw string spec input
.SH "USAGE LINT"
Lint a usage spec file for common issues
.PP
\fBUsage:\fR usage lint [OPTIONS] <FILE>
.PP
\fBOptions:\fR
.PP
.TP
\fB\-f, \-\-format\fR \fI<FORMAT>\fR
Output format
.RS
\fIDefault: \fRtext
.RE
.TP
\fB\-W, \-\-warnings\-as\-errors\fR
Treat warnings as errors
\fBArguments:\fR
.PP
.TP
\fB<FILE>\fR
A usage spec file to lint, use "\-" to read from stdin
.SH "USAGE POWERSHELL"
Execute a shell script with the specified shell

Typically, this will be called by a script's shebang.

If using `var=#true` on args/flags, they will be joined with spaces using `shell_words::join()`
to properly escape and quote values with spaces in them.
.PP
\fBUsage:\fR usage powershell [OPTIONS] <SCRIPT> [<ARGS>] ...
.PP
\fBOptions:\fR
.PP
.TP
\fB\-h\fR
Show help
.TP
\fB\-\-help\fR
Show help
\fBArguments:\fR
.PP
.TP
\fB<ARGS>\fR
Arguments to pass to script
.SH "USAGE ZSH"
Execute a shell script with the specified shell

Typically, this will be called by a script's shebang.

If using `var=#true` on args/flags, they will be joined with spaces using `shell_words::join()`
to properly escape and quote values with spaces in them.
.PP
\fBUsage:\fR usage zsh [OPTIONS] <SCRIPT> [<ARGS>] ...
.PP
\fBOptions:\fR
.PP
.TP
\fB\-h\fR
Show help
.TP
\fB\-\-help\fR
Show help
\fBArguments:\fR
.PP
.TP
\fB<ARGS>\fR
Arguments to pass to script