talented-args 0.2.5-beta → 0.3.1-beta
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 +506 -14
- package/dist/clipboard.d.ts +10 -0
- package/dist/clipboard.js +79 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/compile.d.ts +67 -0
- package/dist/compile.js +188 -0
- package/dist/compile.js.map +1 -0
- package/dist/descriptors.d.ts +322 -0
- package/dist/descriptors.js +362 -0
- package/dist/descriptors.js.map +1 -0
- package/dist/display.d.ts +43 -0
- package/dist/display.js +251 -0
- package/dist/display.js.map +1 -0
- package/dist/errors.d.ts +34 -17
- package/dist/errors.js +61 -75
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +10 -6
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +69 -41
- package/dist/options.js +198 -31
- package/dist/options.js.map +1 -1
- package/dist/parse.d.ts +70 -0
- package/dist/parse.js +551 -0
- package/dist/parse.js.map +1 -0
- package/dist/program.d.ts +125 -0
- package/dist/program.js +337 -0
- package/dist/program.js.map +1 -0
- package/dist/remember.d.ts +71 -0
- package/dist/remember.js +216 -0
- package/dist/remember.js.map +1 -0
- package/dist/styling.d.ts +38 -9
- package/dist/styling.js +155 -75
- package/dist/styling.js.map +1 -1
- package/dist/terminal.d.ts +205 -0
- package/dist/terminal.js +152 -0
- package/dist/terminal.js.map +1 -0
- package/dist/tools.d.ts +35 -31
- package/dist/tools.js +68 -140
- package/dist/tools.js.map +1 -1
- package/dist/tui.d.ts +96 -0
- package/dist/tui.js +397 -0
- package/dist/tui.js.map +1 -0
- package/dist/tui_layout.d.ts +151 -0
- package/dist/tui_layout.js +582 -0
- package/dist/tui_layout.js.map +1 -0
- package/dist/tui_model.d.ts +153 -0
- package/dist/tui_model.js +673 -0
- package/dist/tui_model.js.map +1 -0
- package/package.json +18 -14
- package/.eslintrc.js +0 -24
- package/.idea/codeStyles/Project.xml +0 -364
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/compiler.xml +0 -7
- package/.idea/encodings.xml +0 -6
- package/.idea/inspectionProfiles/Project_Default.xml +0 -12
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -8
- package/.idea/talented-args.iml +0 -11
- package/.idea/vcs.xml +0 -6
- package/.prettierrc.yaml +0 -4
- package/dist/definitions.d.ts +0 -70
- package/dist/definitions.js +0 -38
- package/dist/definitions.js.map +0 -1
- package/dist/main.d.ts +0 -33
- package/dist/main.js +0 -313
- package/dist/main.js.map +0 -1
- package/jest.config.js +0 -4
- package/tsconfig.json +0 -18
package/README.md
CHANGED
|
@@ -1,19 +1,514 @@
|
|
|
1
1
|
# talented-args
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Define command line arguments in the shape of the object your program receives. Talented Args parses the values, infers their TypeScript types, and provides branded help and an interactive command editor.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
```
|
|
6
|
+
npm install talented-args
|
|
7
|
+
```
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
### Features
|
|
9
10
|
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
- Non-framework api (it tells you what it parsed, instead of running your callbacks)
|
|
12
|
+
- TUI mode where the user can pick a command and fill in its options on screen
|
|
13
|
+
- Visually nice (logo, colors, columns)
|
|
14
|
+
- Fully featured (commands, flags, positional args, type conversion, defaults, ...)
|
|
15
|
+
- Fully typed
|
|
16
|
+
- One runtime dependency, [terminal-kit](https://github.com/cronvel/terminal-kit), for terminal display
|
|
17
|
+
|
|
18
|
+
### Demo
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
Source code: [demo/index.ts](demo/index.ts)
|
|
27
|
+
|
|
28
|
+
To try it out:
|
|
29
|
+
- `npm run demo` - run stock demo, TUI mode
|
|
30
|
+
- `npm run demo -- -h` - show the help screen
|
|
31
|
+
- `npm run demo -- backup --help` - show command-specific help
|
|
32
|
+
- `npm run demo -- backup --source ./projects --name nightly --exclude .git --compress` - run the backup command with options.
|
|
33
|
+
|
|
34
|
+
### Example
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { talentedArgs } from 'talented-args';
|
|
38
|
+
|
|
39
|
+
const program = talentedArgs(
|
|
40
|
+
{
|
|
41
|
+
name: 'My app',
|
|
42
|
+
},
|
|
43
|
+
ta => {
|
|
44
|
+
const port = ta.arg(['-p', '--port'], 'Port to use', Number);
|
|
45
|
+
return {
|
|
46
|
+
port,
|
|
47
|
+
verbose: ta.flag(['-v', '--verbose'], 'Verbose mode'),
|
|
48
|
+
webServer: ta.command('serve', 'Start the backend server', {
|
|
49
|
+
port: port.required(),
|
|
50
|
+
host: ta.arg(['--host'], 'Host on which to serve').default('localhost'),
|
|
51
|
+
}),
|
|
52
|
+
migrate: ta.command('migrate', 'Run database migrations', {
|
|
53
|
+
count: ta.arg(['--count'], 'Number of steps', Number).positional().default(1),
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
async function main() {
|
|
60
|
+
const args = await program.parseOrDie();
|
|
61
|
+
|
|
62
|
+
if (args.webServer) {
|
|
63
|
+
console.log(`Starting web server on ${args.webServer.host}:${args.webServer.port}...`);
|
|
64
|
+
}
|
|
65
|
+
if (args.migrate) {
|
|
66
|
+
console.log(`Running ${args.migrate.count} migration steps`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
void main().catch(error => {
|
|
71
|
+
console.error(error);
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
What did we do here:
|
|
77
|
+
1. Define a program with `talentedArgs(options, define)`.
|
|
78
|
+
2. `define` is a callback you use to define your commands, flags, and args.
|
|
79
|
+
3. Call `program.parseOrDie()`. This might trigger the TUI mode if nothing is provided (that's why async), or print help and exit.
|
|
80
|
+
4. On success, you get back an object matching the shape returned by the builder.
|
|
81
|
+
5. Then you use your normal code to decide what to do with this object.
|
|
82
|
+
|
|
83
|
+
### Documentation
|
|
84
|
+
|
|
85
|
+
- [Define options](#define-options)
|
|
86
|
+
- [Convert and validate values](#convert-and-validate-values)
|
|
87
|
+
- [Lists and positional arguments](#lists-and-positional-arguments)
|
|
88
|
+
- [Commands, groups, and shared options](#commands-groups-and-shared-options)
|
|
89
|
+
- [Run metadata](#run-metadata)
|
|
90
|
+
- [Parse arguments](#parse-arguments)
|
|
91
|
+
- [Interactive mode](#interactive-mode)
|
|
92
|
+
- [Remember interactive values](#remember-interactive-values)
|
|
93
|
+
- [Program options and help](#program-options-and-help)
|
|
94
|
+
- [TypeScript types](#typescript-types)
|
|
95
|
+
|
|
96
|
+
#### Define options
|
|
97
|
+
|
|
98
|
+
The object you return from the callback is the shape of the object you get back. Option names are what the user types. You pick the property names yourself, so `--name` can end up in `args.userName`:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
const program = talentedArgs({ name: 'My app' }, ta => ({
|
|
102
|
+
userName: ta.arg(['-n', '--name'], 'User name'),
|
|
103
|
+
port: ta.arg(['-p', '--port'], 'TCP port', Number).default(8080),
|
|
104
|
+
verbose: ta.flag(['-v', '--verbose'], 'Print more details').default(false),
|
|
105
|
+
}));
|
|
106
|
+
|
|
107
|
+
program.parse(['--name', 'Alice']);
|
|
108
|
+
// { kind: 'parsed', args: { userName: 'Alice', port: 8080, verbose: false }, command: null }
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
| Definition | What you get when it's given | If it's left out |
|
|
112
|
+
| ------------------------------------- | ---------------------------- | ------------------ |
|
|
113
|
+
| `ta.arg(names, description)` | A string, such as `"8080"` | Property is absent |
|
|
114
|
+
| `ta.arg(names, description, convert)` | The converter's return value | Property is absent |
|
|
115
|
+
| `ta.flag(names, description)` | `true`; flags take no value | Property is absent |
|
|
116
|
+
|
|
117
|
+
Give `names` one spelling, like `'--port'`, or a non-empty array, like `['-p', '--port']`. Long names start with `--`; short aliases are one character after `-` and can't be digits. Names are case-sensitive, and spaces or `=` aren't allowed. You have to pass a description, but an empty string is fine.
|
|
118
|
+
|
|
119
|
+
These methods return new descriptors, so they don't change the original. Keep the version they return:
|
|
120
|
+
|
|
121
|
+
| Method | Applies to | Effect |
|
|
122
|
+
| -------------------- | ------------------------ | ---------------------------------------------------------------------- |
|
|
123
|
+
| `.required()` | Values and lists | The user has to give a value, or at least one list item |
|
|
124
|
+
| `.default(value)` | Values, lists, and flags | Use this value when the option is left out |
|
|
125
|
+
| `.label('TCP_PORT')` | Values and lists | Show a custom value label in help |
|
|
126
|
+
| `.multiple()` | Values | Take several values and give you an array |
|
|
127
|
+
| `.positional()` | Values and lists | Also take values without the option name |
|
|
128
|
+
| `.sensitive()` | Values and lists | Hide values on screen and in errors, and don't save them |
|
|
129
|
+
| `.negatable()` | Flags with a long name | Also take `--no-<name>`, which sets the flag to `false` |
|
|
130
|
+
|
|
131
|
+
Defaults don't go through the converter, so a number needs a numeric default, like `.default(8080)`. Calling `.required()` drops any previous default, and `.default()` replaces a previous requirement. If you want a list, call `.multiple()` before either of them.
|
|
132
|
+
|
|
133
|
+
`0`, `false`, and an empty string all count as values. If a flag wasn't given, its property is left out unless you set a default. Use `.default(false)` if you'd rather get `false` when the user leaves it out.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const program = talentedArgs({ name: 'My app' }, ta => ({
|
|
137
|
+
color: ta.flag('--color', 'Use colors').negatable().default(true),
|
|
138
|
+
}));
|
|
139
|
+
|
|
140
|
+
program.parse(['--no-color']);
|
|
141
|
+
// { kind: 'parsed', args: { color: false }, command: null }
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
With `.negatable()`, each long name gets a `--no-` version. If you've defined an option called `--no-color` yourself, that option wins.
|
|
145
|
+
|
|
146
|
+
#### Convert and validate values
|
|
147
|
+
|
|
148
|
+
A converter takes the text the user typed and turns it into the value you want. Throw an error if the value isn't OK. The user sees your error message, unless the argument is marked sensitive.
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
const program = talentedArgs({ name: 'My app' }, ta => ({
|
|
152
|
+
port: ta.arg('--port', 'TCP port', value => {
|
|
153
|
+
const port = Number(value);
|
|
154
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
155
|
+
throw new Error('Port must be an integer between 1 and 65535');
|
|
156
|
+
}
|
|
157
|
+
return port;
|
|
158
|
+
}).default(8080),
|
|
159
|
+
}));
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
`Number` here is stricter than the usual `Number()`. Decimal, exponent, hexadecimal, octal, and binary values are fine, as long as the result is finite. Empty text, just spaces, `NaN`, and infinity aren't. We also reject `NaN` from a custom converter, but any other checks are up to you.
|
|
163
|
+
|
|
164
|
+
Converters have to return the value right away. Promises aren't supported, and both TypeScript and the runtime check for that. `Boolean` isn't supported either, since it would turn every non-empty string into `true`. Use `ta.flag()` for a switch, or write your own converter for text like `'true'` and `'false'`.
|
|
165
|
+
|
|
166
|
+
#### Lists and positional arguments
|
|
167
|
+
|
|
168
|
+
Normally, each item needs its own option name: `--tag a --tag b`. With `.multiple({ greedy: true })`, it keeps taking values until it reaches another option or `--`.
|
|
169
|
+
|
|
170
|
+
A positional argument lets you leave out the option name. The common options and the selected command can have only one positional input between them. If that input is a list, it takes several bare values, with or without `greedy`.
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
const program = talentedArgs({ name: 'Seeder' }, ta => ({
|
|
174
|
+
seed: ta.command('seed', 'Seed records', {
|
|
175
|
+
ids: ta.arg('--id', 'Record IDs', Number)
|
|
176
|
+
.multiple({ greedy: true })
|
|
177
|
+
.positional()
|
|
178
|
+
.required(),
|
|
179
|
+
tags: ta.arg('--tag', 'Tags').multiple().default([]),
|
|
180
|
+
}),
|
|
181
|
+
}));
|
|
182
|
+
|
|
183
|
+
program.parse(['seed', '1', '2', '3', '--tag', 'important']);
|
|
184
|
+
// { kind: 'parsed', args: { seed: { ids: [1, 2, 3], tags: ['important'] } }, command: 'seed' }
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
If no values were given, the list property is left out. Use `.multiple().default([])` if you'd rather get an empty array.
|
|
188
|
+
|
|
189
|
+
#### Commands, groups, and shared options
|
|
190
|
+
|
|
191
|
+
Same idea as option names: the user types the command token, and you pick where its arguments go in the result. In the opening example, the command is `serve`, and you get its values in `args.webServer`.
|
|
192
|
+
|
|
193
|
+
Only the chosen command's property is there. Options outside commands are common options, so they work before or after the command name. A command's own options go after it. With a greedy common list, put the command first, or the list might take its name as another value.
|
|
194
|
+
|
|
195
|
+
A command with no arguments, like `ta.command('status', 'Show status')`, gives you an empty object when picked. It can still use common options. Commands go at the top level; we don't have nested commands. Their names can't be empty, start with a dash, or contain spaces or `=`.
|
|
196
|
+
|
|
197
|
+
If a command needs more explanation, pass `{ summary, details }` instead of a string. The list shows `summary`, and command help shows `details`.
|
|
198
|
+
|
|
199
|
+
You can put plain objects in there too, to group the returned values:
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
const program = talentedArgs({ name: 'My app' }, ta => ({
|
|
203
|
+
database: {
|
|
204
|
+
host: ta.arg('--host', 'Database host'),
|
|
205
|
+
port: ta.arg('--port', 'Database port', Number).default(5432),
|
|
206
|
+
},
|
|
207
|
+
}));
|
|
208
|
+
|
|
209
|
+
program.parse([]);
|
|
210
|
+
// { kind: 'parsed', args: { database: { port: 5432 } }, command: null }
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The group is always there, even if none of its optional arguments were given. The option is still `--host`; its value ends up in `args.database.host`.
|
|
214
|
+
|
|
215
|
+
To share an option, define it once and use it in more than one place:
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
const program = talentedArgs({ name: 'My app' }, ta => {
|
|
219
|
+
const port = ta.arg('--port', 'TCP port', Number);
|
|
220
|
+
return {
|
|
221
|
+
port,
|
|
222
|
+
server: ta.command('serve', 'Start the server', {
|
|
223
|
+
port: port.default(8080),
|
|
224
|
+
}),
|
|
225
|
+
};
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
program.parse(['serve', '--port', '9000']);
|
|
229
|
+
// { kind: 'parsed', args: { port: 9000, server: { port: 9000 } }, command: 'serve' }
|
|
230
|
+
|
|
231
|
+
program.parse(['serve']);
|
|
232
|
+
// { kind: 'parsed', args: { server: { port: 8080 } }, command: 'serve' }
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
When you give a shared option a value, it shows up everywhere you placed it for that run. `.required()` and `.default()` belong to each particular place. In the second parse above, `args.server.port` gets its default, while `args.port` stays missing.
|
|
236
|
+
|
|
237
|
+
Do things like `.multiple()`, `.positional()`, `.label()`, `.sensitive()`, and `.negatable()` before sharing. Those methods make a different input, so reusing the original alongside the changed one would give you two options with the same name. That's an error when both are available in the same run. Different commands can reuse names, since you only pick one at a time.
|
|
238
|
+
|
|
239
|
+
#### Run metadata
|
|
240
|
+
|
|
241
|
+
Put `ta.meta()` wherever you'd like the result to tell you which command ran and whether the user went through the editor. It adds `{ command, interactive }` without adding another command line option.
|
|
242
|
+
|
|
243
|
+
| Property | Meaning |
|
|
244
|
+
| ------------- | ------------------------------------------------------------------ |
|
|
245
|
+
| `command` | The command name, or `null` if no command was picked |
|
|
246
|
+
| `interactive` | `true` if the user went through the editor, otherwise `false` |
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
const program = talentedArgs({ name: 'My app', missingCommandPolicy: 'none' }, ta => ({
|
|
250
|
+
run: ta.meta(),
|
|
251
|
+
status: ta.command('status', 'Show status'),
|
|
252
|
+
}));
|
|
253
|
+
|
|
254
|
+
program.parse([]);
|
|
255
|
+
// { kind: 'parsed', args: { run: { command: null, interactive: false } }, command: null }
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
You can put metadata at the top level, in a group, or inside a command. It's always there when that part of the result is there. If the program has no commands, `command` is always `null`.
|
|
259
|
+
|
|
260
|
+
#### Parse arguments
|
|
261
|
+
|
|
262
|
+
For a command line app, use `parseOrDie()`. Give it the whole `process.argv`, including the Node and script paths, or just call it with no arguments and it'll use that for you.
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
async function main() {
|
|
266
|
+
const args = await program.parseOrDie();
|
|
267
|
+
// Use the parsed arguments to run your application.
|
|
268
|
+
console.log(args);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
void main().catch(error => {
|
|
272
|
+
console.error(error);
|
|
273
|
+
process.exitCode = 1;
|
|
274
|
+
});
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
If all goes well, you get your object back. It also takes care of help, bad arguments, and the editor:
|
|
278
|
+
|
|
279
|
+
| Situation | Behavior | Exit code |
|
|
280
|
+
| ----------------------------------------- | ---------------------------------------------------------------- | --------- |
|
|
281
|
+
| `-h` or `--help` | Print help to stdout | `0` |
|
|
282
|
+
| Invalid input or a missing required value | Explain what's wrong on stderr | `1` |
|
|
283
|
+
| Interactive mode cancelled | Put the terminal back as it was and exit | `130` |
|
|
284
|
+
| Command copied from the editor | Print the masked command to stdout and try to copy it | `0` |
|
|
285
|
+
|
|
286
|
+
You can also import these codes as `TALENTED_ARGS_EXIT_CODES`. Its keys are `help`, `usage`, `cancelled`, and `copied`.
|
|
287
|
+
|
|
288
|
+
If you want to handle those decisions yourself, or you're writing a test, use `parse(tokens)`. Give it just the arguments, without the Node and script paths. It returns right away, without printing, exiting, opening the editor, or reading saved values.
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
const result = program.parse(['serve', '--port', '8080']);
|
|
292
|
+
if (result.kind === 'parsed') {
|
|
293
|
+
console.log(result.args);
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
| `result.kind` | Result |
|
|
298
|
+
| ----------------- | -------------------------------------------------------------- |
|
|
299
|
+
| `'parsed'` | `{ kind, args, command }`, with the values converted and checked |
|
|
300
|
+
| `'help'` | `{ kind, command }`, saying which help page to show |
|
|
301
|
+
| `'needs-command'` | `{ kind }`, when the user needs to pick a command |
|
|
302
|
+
| `'interactive'` | `{ kind, command }`, when the user asked for `--interactive` |
|
|
303
|
+
|
|
304
|
+
`parse()` throws `TalentedArgsUsageError` if something's wrong. Help wins over other usage errors. With `--interactive`, values don't get converted or checked for missing requirements yet, since the user can fix them in the editor. The command line still has to make sense, though.
|
|
305
|
+
|
|
306
|
+
Both methods understand `--port=8080`, `--port 8080`, and short aliases. A bare negative number counts as a value. For other values that start with a dash, use `=`, like `--name=-example`. Everything after `--` goes to the positional argument, so put the command name before it. Giving a single-value option or flag twice is an error. Lists keep the order you gave them in.
|
|
307
|
+
|
|
308
|
+
`-h`, `--help`, `--interactive`, and `--no-interactive` are taken by the library, so you can't define your own options with those names. If both interactive switches are given, `--no-interactive` wins, whichever comes first.
|
|
309
|
+
|
|
310
|
+
`TalentedArgsUsageError` has an `issues` array. Each issue has a `code`, a `message`, and the `option` it's about. The error's own `code` and `option` come from the first issue.
|
|
311
|
+
|
|
312
|
+
`TalentedArgsDefinitionError` means something's wrong with the program definition, a converter returned something unsupported, or you asked for help for a command that doesn't exist. `parseOrDie()` handles usage errors, but leaves other errors for your code to catch. Both error classes extend `TalentedArgsError`. Their `status` values are `400` and `500`; those describe the error, not the process exit code.
|
|
313
|
+
|
|
314
|
+
#### Interactive mode
|
|
315
|
+
|
|
316
|
+
If your program has commands and the user doesn't pick one, the editor opens. They pick a command, fill in its options, and hit Run, Copy, or Cancel. If your program has no commands, it just runs, unless the user asks for `--interactive`.
|
|
317
|
+
|
|
318
|
+
You can change that with `missingCommandPolicy`:
|
|
319
|
+
|
|
320
|
+
| Policy | `parseOrDie()` behavior | `parse()` result |
|
|
321
|
+
| -------------------- | ----------------------------------------------------------------------------- | -------------------------------- |
|
|
322
|
+
| `'tui'`, the default | Open the editor. If there's no suitable terminal, show help and exit with code 1 | `'needs-command'` |
|
|
323
|
+
| `'error'` | Print help and exit with code 1 | `'needs-command'` |
|
|
324
|
+
| `'none'` | Return the common arguments, with no command property | `'parsed'`, with `command: null` |
|
|
325
|
+
|
|
326
|
+
`'none'` also puts a no-command choice in the editor. `ta.meta()` tells you if that's what the user picked. These policies only matter when your program has commands. The user can still ask for `--interactive` with any of them.
|
|
327
|
+
|
|
328
|
+
The editor needs a terminal for input and output, and `TERM` has to be set to something other than `dumb`. Setting `CI` disables it, unless its value is `''`, `'0'`, or `'false'`. If stdout is piped somewhere but stderr is a terminal, we draw on stderr. Asking for `--interactive` when there's no suitable terminal gives a usage error.
|
|
329
|
+
|
|
330
|
+
| Key | Action |
|
|
331
|
+
| ----------------------- | -------------------------------------------------------------------------- |
|
|
332
|
+
| Up / Down | Move through commands or fields |
|
|
333
|
+
| Enter | Open a command, go to the next field, or press the selected button |
|
|
334
|
+
| Tab / Shift-Tab | Switch between commands, fields, and buttons |
|
|
335
|
+
| Space on a flag | Toggle it; negatable flags cycle through unset, `true`, and `false` |
|
|
336
|
+
| Ctrl-U in a text field | Clear the field |
|
|
337
|
+
| Left / Right on buttons | Choose Run, Copy, or Cancel |
|
|
338
|
+
| Ctrl-R | Check the values and run |
|
|
339
|
+
| Ctrl-Y | Check the values and copy, then exit without running |
|
|
340
|
+
| Escape | Return to command selection, or cancel from there |
|
|
341
|
+
| Ctrl-C | Cancel |
|
|
342
|
+
|
|
343
|
+
Leave a text field blank to leave the option out. Type `""` if you actually want an empty string. A single-value field strips one pair of quotes around the whole value. In a list field, separate items with spaces. Single or double quotes and backslash escapes work there too.
|
|
344
|
+
|
|
345
|
+
Sensitive values are hidden in the preview and the printed command. The clipboard copy keeps the real values, so you can run it as-is. We first try a system clipboard tool, then ask the terminal using an OSC 52 escape sequence. That can work over SSH too, but the terminal doesn't tell us whether it worked. Either way, the command is printed to stdout.
|
|
346
|
+
|
|
347
|
+
#### Remember interactive values
|
|
348
|
+
|
|
349
|
+
Set `remember` to have the editor start where you left it after the last Run or Copy. Each command keeps its own values, and the common ones are shared. Anything you give on the command line wins over what was remembered, including which command to start on.
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
const program = talentedArgs({ name: 'My app', remember: true }, ta => ({
|
|
353
|
+
server: ta.command('serve', 'Start the server', {
|
|
354
|
+
host: ta.arg('--host', 'Host').default('localhost'),
|
|
355
|
+
}),
|
|
356
|
+
}));
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
| `remember` | Storage |
|
|
360
|
+
| ---------------------- | ----------------------------------------------------------- |
|
|
361
|
+
| `true` | Default system state file |
|
|
362
|
+
| `'/path/to/file.json'` | Your file. Relative paths start at the working directory. |
|
|
363
|
+
| `{ load, save }` | Your own storage methods. You can leave out `save`. |
|
|
364
|
+
| `false` or omitted | Don't remember anything |
|
|
365
|
+
|
|
366
|
+
Default file locations are:
|
|
367
|
+
|
|
368
|
+
| Platform | Path |
|
|
369
|
+
| -------- | ------------------------------------------------------- |
|
|
370
|
+
| Linux | `~/.local/state/<name>/interactive.json` |
|
|
371
|
+
| macOS | `~/Library/Application Support/<name>/interactive.json` |
|
|
372
|
+
| Windows | `%LOCALAPPDATA%\<name>\interactive.json` |
|
|
373
|
+
|
|
374
|
+
If `XDG_STATE_HOME` is an absolute path, we use that as the base directory on any platform. `<name>` comes from your app's package name, or the `name` option if there's no package name. We lowercase it and turn characters that don't work in a directory name into hyphens. Programs from the same package share the file, so give them their own paths if you'd like them to remember different things.
|
|
375
|
+
|
|
376
|
+
We only save what you Run or Copy from the editor. Cancelling doesn't save anything, and a normal command line doesn't read or write remembered values. Sensitive values are never saved. If the file is missing or broken, we start fresh. A failed write won't stop the command from running.
|
|
377
|
+
|
|
378
|
+
If you bring your own store, it gets the raw values under their option names, like `'--host'`. `load()` returns an object with optional `command`, `common`, and `commands` properties:
|
|
379
|
+
|
|
380
|
+
```json
|
|
381
|
+
{
|
|
382
|
+
"command": "serve",
|
|
383
|
+
"common": { "--verbose": true },
|
|
384
|
+
"commands": { "serve": { "--host": "localhost" } }
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Both methods can return promises. This example just keeps values in memory. Swap in your own storage if you want them to survive between runs:
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
import type { TalentedArgsRemembered, TalentedArgsRememberStore } from 'talented-args';
|
|
392
|
+
|
|
393
|
+
let saved: TalentedArgsRemembered | null = null;
|
|
394
|
+
const remember: TalentedArgsRememberStore = {
|
|
395
|
+
load: () => saved,
|
|
396
|
+
save: values => {
|
|
397
|
+
saved = values;
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
const program = talentedArgs({ name: 'My app', remember }, ta => ({
|
|
402
|
+
host: ta.arg('--host', 'Host'),
|
|
403
|
+
}));
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Leave out `save()` if you only want to fill in some starting values. `load()` can return `null` or `undefined` when there's nothing to load. If your store throws an error, it comes back to your code.
|
|
407
|
+
|
|
408
|
+
You can store strings, numbers, booleans, or arrays of strings and numbers. We skip commands and options that no longer exist, values in the wrong format, and lists that no longer fit the option. The text goes through the current converters again. If it doesn't convert anymore, it stays in the editor so the user can fix it.
|
|
409
|
+
|
|
410
|
+
#### Program options and help
|
|
411
|
+
|
|
412
|
+
These go in the first argument to `talentedArgs()`:
|
|
413
|
+
|
|
414
|
+
| Option | What it does | Default |
|
|
415
|
+
| ---------------------- | --------------------------------------------------- | ---------------------------------------------- |
|
|
416
|
+
| `name` | Name shown in help and the editor | Application package name |
|
|
417
|
+
| `description` | Program description | Application package description |
|
|
418
|
+
| `version` | Version shown in help | Application package version, prefixed with `v` |
|
|
419
|
+
| `executable` | How to start the app, shown in help and previews | Application script filename |
|
|
420
|
+
| `logoPath` | UTF-8 text file containing an ASCII or Unicode logo | No logo |
|
|
421
|
+
| `styles` | Colors and other text styles | Built-in styles |
|
|
422
|
+
| `missingCommandPolicy` | What to do when there are commands but none was picked | `'tui'` |
|
|
423
|
+
| `remember` | Where the editor keeps previous values | `false` |
|
|
424
|
+
|
|
425
|
+
We look for the nearest readable `package.json` above your app's script. That's where the name, description, and version come from unless you give them yourself. A version you pass in is shown exactly as you wrote it.
|
|
426
|
+
|
|
427
|
+
`--help` shows the program's help, and `serve --help` shows help for that command. You can also get the help as a string:
|
|
428
|
+
|
|
429
|
+
```typescript
|
|
430
|
+
const help = program.help(null, { width: 100, color: false, executable: 'my-app' });
|
|
431
|
+
const commandHelp = program.help('serve');
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
`help()` with no command gives you the program's help. The default width is 80, with colors off. For command help, use the name you'd type, like `serve`, rather than the result property, like `webServer`.
|
|
435
|
+
|
|
436
|
+
A style can be one name, an array of names, or `null`. `styles: null` turns off all the configured styles. Set one entry to `null` to turn off just that style. Anything you leave out keeps its default.
|
|
437
|
+
|
|
438
|
+
```typescript
|
|
439
|
+
const program = talentedArgs(
|
|
440
|
+
{
|
|
441
|
+
name: 'My app',
|
|
442
|
+
styles: {
|
|
443
|
+
banner_logo: 'magenta',
|
|
444
|
+
banner_title: ['bold', 'underline'],
|
|
445
|
+
accent: 'cyan',
|
|
446
|
+
option_name: null,
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
ta => ({ verbose: ta.flag('--verbose', 'Print more details') })
|
|
450
|
+
);
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
The style keys are `command_name`, `command_summary`, `banner_title`, `banner_description`, `banner_logo`, `banner_footer`, `section_title`, `option_name`, `option_label`, `accent`, and `error`.
|
|
454
|
+
|
|
455
|
+
You can use the usual colors, bright versions like `cyanBright`, backgrounds like `bgBlue`, and text effects: `bold`, `dim`, `italic`, `underline`, `inverse`, `hidden`, and `strikethrough`. If an array has several colors, the later ones win. The editor's controls use the terminal's default colors, with the accent for decoration.
|
|
456
|
+
|
|
457
|
+
Help uses terminal colors when it can. A non-empty `NO_COLOR` turns them off; otherwise, `FORCE_COLOR` can turn them on. Piped output is normally plain text. The editor still uses its terminal controls regardless of these color settings.
|
|
458
|
+
|
|
459
|
+
#### TypeScript types
|
|
460
|
+
|
|
461
|
+
The types come from what you defined. `.required()` and `.default()` make an argument property non-optional. Other arguments and command properties are optional. Groups and metadata are always there when the part of the result containing them is there.
|
|
462
|
+
|
|
463
|
+
If you need a name for the type you get back, use `TalentedParsedArgs`:
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
import type { TalentedParsedArgs } from 'talented-args';
|
|
467
|
+
|
|
468
|
+
type AppArgs = TalentedParsedArgs<typeof program>;
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
For commands named `serve` and `migrate`, the metadata's `command` type is `'serve' | 'migrate' | null`. Check `args.webServer` before using its arguments. TypeScript won't know it's there just because the metadata says `serve`.
|
|
472
|
+
|
|
473
|
+
If you already have a type for your settings, `TalentedArgsGuidedShape` and `satisfies` let you check the definition against it:
|
|
474
|
+
|
|
475
|
+
```typescript
|
|
476
|
+
import type { TalentedArgsGuidedShape } from 'talented-args';
|
|
477
|
+
|
|
478
|
+
interface AppSettings {
|
|
479
|
+
port: number;
|
|
480
|
+
verbose?: boolean;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
const program = talentedArgs(
|
|
484
|
+
{ name: 'My app' },
|
|
485
|
+
ta => ({
|
|
486
|
+
port: ta.arg('--port', 'TCP port', Number).default(8080),
|
|
487
|
+
verbose: ta.flag('--verbose', 'Print more details'),
|
|
488
|
+
} satisfies TalentedArgsGuidedShape<AppSettings>)
|
|
489
|
+
);
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
The guide checks that you defined every property, even the optional ones. You can still add more. The type you get back comes from what you actually defined. The guide doesn't decide which values the user has to give: `.required()` does that, and `.default()` fills in a value when they don't.
|
|
14
493
|
|
|
15
494
|
### Release log
|
|
16
495
|
|
|
496
|
+
#### 0.3.1-beta
|
|
497
|
+
|
|
498
|
+
- TUI is now centered on the screen, and uses the same header as the --help screen.
|
|
499
|
+
- Add demo images to the README.
|
|
500
|
+
|
|
501
|
+
#### 0.3.0-beta
|
|
502
|
+
|
|
503
|
+
- New API. Args are defined in a callback, in the shape of the result, and the result is typed from the definition.
|
|
504
|
+
- Interactive mode for programs with commands.
|
|
505
|
+
- `command-line-args`, `command-line-usage`, `table-layout` and `colorette` are replaced by `util.parseArgs` from node and by `terminal-kit`.
|
|
506
|
+
- Invalid numbers, missing values, and unknown options are reported instead of slipping through.
|
|
507
|
+
- Common options are accepted after the command too.
|
|
508
|
+
- Interactive mode can start with what was entered the last time (`remember`).
|
|
509
|
+
- Interactive mode can copy the command line instead of running it.
|
|
510
|
+
- `missingCommandPolicy` says what a program does when it is started without a command, and `ta.meta()` puts the picked command in the result.
|
|
511
|
+
|
|
17
512
|
#### 0.2.5-beta
|
|
18
513
|
|
|
19
514
|
- Add `allowNoCommand` option
|
|
@@ -26,21 +521,18 @@ Added stuff:
|
|
|
26
521
|
|
|
27
522
|
- Improved typings
|
|
28
523
|
|
|
29
|
-
#### 0.2.1-beta
|
|
30
|
-
|
|
31
|
-
- Improved typings
|
|
32
|
-
|
|
33
524
|
#### 0.2.0-beta
|
|
34
525
|
|
|
35
526
|
- Add (typed) support for multiple commands per type definition.
|
|
36
527
|
- Print out command name on the command-specific help screen.
|
|
37
|
-
- Allow user to define command details, to be shown on the command-specific screen.
|
|
38
|
-
Backwards compatible changes.
|
|
528
|
+
- Allow user to define command details, to be shown on the command-specific screen. Backwards compatible changes.
|
|
39
529
|
|
|
40
530
|
### Stability
|
|
41
531
|
|
|
42
532
|
This library is currently in **_BETA_**. There are likely bugs, and API-s might change. It shouldn't be used by anyone but me.
|
|
43
533
|
|
|
534
|
+
The interactive mode was tested on Linux. It still has to be tried on macOS.
|
|
535
|
+
|
|
44
536
|
### License
|
|
45
537
|
|
|
46
538
|
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ITerminalOutput } from './terminal';
|
|
2
|
+
/** Clipboard commands to try for the platform and available display environment. */
|
|
3
|
+
export declare function clipboardTools(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): (readonly [string, ...string[]])[];
|
|
4
|
+
/** OSC 52 escape sequence requesting a terminal clipboard copy. */
|
|
5
|
+
export declare function clipboardEscape(text: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Copy text using a system clipboard tool, falling back to OSC 52.
|
|
8
|
+
* Returns `true` only when a tool reports success. OSC 52 provides no confirmation.
|
|
9
|
+
*/
|
|
10
|
+
export declare function copyToClipboard(text: string, terminal: ITerminalOutput, env: NodeJS.ProcessEnv, platform?: NodeJS.Platform, toolTimeoutMs?: number): Promise<boolean>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clipboardTools = clipboardTools;
|
|
4
|
+
exports.clipboardEscape = clipboardEscape;
|
|
5
|
+
exports.copyToClipboard = copyToClipboard;
|
|
6
|
+
const node_child_process_1 = require("node:child_process");
|
|
7
|
+
/**
|
|
8
|
+
* Clipboard support for terminal programs.
|
|
9
|
+
* System clipboard tools can report success. If no tool succeeds, use the terminal's OSC 52
|
|
10
|
+
* escape sequence. Terminal copying can work over SSH but provides no confirmation.
|
|
11
|
+
*/
|
|
12
|
+
/** Maximum wait for a clipboard tool, in milliseconds. */
|
|
13
|
+
const TOOL_TIMEOUT_MS = 2000;
|
|
14
|
+
/** Clipboard commands to try for the platform and available display environment. */
|
|
15
|
+
function clipboardTools(platform, env) {
|
|
16
|
+
if (platform === 'darwin') {
|
|
17
|
+
return [['pbcopy']];
|
|
18
|
+
}
|
|
19
|
+
if (platform === 'win32') {
|
|
20
|
+
return [['clip']];
|
|
21
|
+
}
|
|
22
|
+
const tools = [];
|
|
23
|
+
if (env['WAYLAND_DISPLAY']) {
|
|
24
|
+
tools.push(['wl-copy']);
|
|
25
|
+
}
|
|
26
|
+
if (env['DISPLAY']) {
|
|
27
|
+
tools.push(['xclip', '-selection', 'clipboard'], ['xsel', '--clipboard', '--input']);
|
|
28
|
+
}
|
|
29
|
+
if (env['WSL_DISTRO_NAME']) {
|
|
30
|
+
tools.push(['clip.exe']);
|
|
31
|
+
}
|
|
32
|
+
return tools;
|
|
33
|
+
}
|
|
34
|
+
/** Write text to a clipboard tool. Returns `true` when it exits successfully. */
|
|
35
|
+
function runTool([command, ...args], text, env, timeoutMs) {
|
|
36
|
+
return new Promise(resolve => {
|
|
37
|
+
// Ignore tool output. X11 clipboard tools can remain in the background,
|
|
38
|
+
// which would keep stdout and stderr pipes open after copying.
|
|
39
|
+
const child = (0, node_child_process_1.spawn)(command, args, {
|
|
40
|
+
env,
|
|
41
|
+
stdio: ['pipe', 'ignore', 'ignore'],
|
|
42
|
+
windowsHide: true,
|
|
43
|
+
});
|
|
44
|
+
// Use a timer we can clear when spawning fails, so missing tools leave no pending timeout.
|
|
45
|
+
const timer = setTimeout(() => child.kill(), timeoutMs).unref();
|
|
46
|
+
const finish = (ok) => {
|
|
47
|
+
clearTimeout(timer);
|
|
48
|
+
resolve(ok);
|
|
49
|
+
};
|
|
50
|
+
child.on('error', () => finish(false));
|
|
51
|
+
child.on('exit', code => finish(code === 0));
|
|
52
|
+
// Ignore stdin errors from missing or stopped tools; process events report whether copying succeeded.
|
|
53
|
+
child.stdin.on('error', () => undefined);
|
|
54
|
+
child.stdin.end(text);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** OSC 52 escape sequence requesting a terminal clipboard copy. */
|
|
58
|
+
function clipboardEscape(text) {
|
|
59
|
+
return `\x1b]52;c;${Buffer.from(text, 'utf8').toString('base64')}\x07`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Copy text using a system clipboard tool, falling back to OSC 52.
|
|
63
|
+
* Returns `true` only when a tool reports success. OSC 52 provides no confirmation.
|
|
64
|
+
*/
|
|
65
|
+
async function copyToClipboard(text, terminal, env, platform = process.platform, toolTimeoutMs = TOOL_TIMEOUT_MS) {
|
|
66
|
+
for (const tool of clipboardTools(platform, env)) {
|
|
67
|
+
if (await runTool(tool, text, env, toolTimeoutMs)) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Skip OSC 52 on the Linux console, which would display the sequence as text.
|
|
72
|
+
if (env['TERM'] !== 'linux') {
|
|
73
|
+
await new Promise(resolve => {
|
|
74
|
+
terminal.write(clipboardEscape(text), () => resolve());
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=clipboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../src/clipboard.ts"],"names":[],"mappings":"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"}
|