@kud/cli-shot 0.1.2 → 0.2.0
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 +20 -15
- package/dist/{chunk-RT6Y4NTY.js → chunk-NTFITNMX.js} +12 -1
- package/dist/cli.js +9 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,28 +39,33 @@ brew install charmbracelet/tap/freeze # the renderer
|
|
|
39
39
|
cli-shot --out assets/screenshots -- pcloud
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
Everything after `--` is the command being driven
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
Everything after `--` is the command being driven, so its own flags stay clear
|
|
43
|
+
of cli-shot's.
|
|
44
|
+
|
|
45
|
+
Two exceptions: cli-shot appends `--mock` and `--screen` to that command itself.
|
|
46
|
+
Passing either one yourself leaves two in argv — the app reads the first while
|
|
47
|
+
the filename comes from the second, which is how you get a `files.png` holding
|
|
48
|
+
the Sync screen. cli-shot refuses rather than guessing, and points you at
|
|
49
|
+
`--only` or `--no-mock`.
|
|
45
50
|
|
|
46
51
|
```sh
|
|
47
|
-
cli-shot --out shots --
|
|
52
|
+
cli-shot --out shots --only sync -- pcloud # one screen
|
|
48
53
|
cli-shot --out shots --list -- pcloud # what screens exist
|
|
49
54
|
cli-shot --out shots --keys $'jjj\r' -- pcloud # drive deeper first
|
|
50
55
|
cli-shot --out shots --no-mock -- pcloud # real data (careful)
|
|
51
56
|
```
|
|
52
57
|
|
|
53
|
-
| flag
|
|
54
|
-
|
|
|
55
|
-
| `-o, --out <dir>`
|
|
56
|
-
|
|
|
57
|
-
| `--list`
|
|
58
|
-
| `--cols` / `--rows`
|
|
59
|
-
| `--settle <ms>`
|
|
60
|
-
| `--jobs <n>`
|
|
61
|
-
| `--keys <sequence>`
|
|
62
|
-
| `--font <family>`
|
|
63
|
-
| `--no-mock`
|
|
58
|
+
| flag | |
|
|
59
|
+
| ------------------- | ------------------------------------------------- |
|
|
60
|
+
| `-o, --out <dir>` | directory to write PNGs into |
|
|
61
|
+
| `--only <screen>` | shoot one screen instead of every screen |
|
|
62
|
+
| `--list` | print the screens the command offers, and stop |
|
|
63
|
+
| `--cols` / `--rows` | terminal size (default 110×32) |
|
|
64
|
+
| `--settle <ms>` | how long the screen must hold still (default 350) |
|
|
65
|
+
| `--jobs <n>` | screens shot at once; defaults to the core count |
|
|
66
|
+
| `--keys <sequence>` | keystrokes sent once the screen has drawn |
|
|
67
|
+
| `--font <family>` | font to render with; defaults to a Nerd Font |
|
|
68
|
+
| `--no-mock` | drive real data instead of fixtures |
|
|
64
69
|
|
|
65
70
|
## The contract
|
|
66
71
|
|
|
@@ -161,8 +161,18 @@ var toImage = (ansi, output, { font = DEFAULT_FONT, freezeArgs = [] } = {}) => {
|
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
// src/index.ts
|
|
164
|
+
var MANAGED_FLAGS = ["--screen", "--mock"];
|
|
165
|
+
var assertNoManagedFlags = (args) => {
|
|
166
|
+
const clash = MANAGED_FLAGS.find((flag) => args.includes(flag));
|
|
167
|
+
if (!clash) return;
|
|
168
|
+
throw new Error(
|
|
169
|
+
`${clash} is set by cli-shot, so passing it to the driven command leaves two in argv.
|
|
170
|
+
` + (clash === "--screen" ? ` Use cli-shot's --only <screen> instead, before the --.` : ` Mock data is on by default; use cli-shot's --no-mock to turn it off.`)
|
|
171
|
+
);
|
|
172
|
+
};
|
|
164
173
|
var screenArgs = (args, screen, mock) => [...args, ...mock ? ["--mock"] : [], "--screen", screen];
|
|
165
174
|
var shootScreen = async (screen, { command, args = [], out, mock = true, ...rest }) => {
|
|
175
|
+
assertNoManagedFlags(args);
|
|
166
176
|
const ansi = await capture(command, screenArgs(args, screen, mock), rest);
|
|
167
177
|
return toImage(ansi, join(out, `${screen}.png`), rest);
|
|
168
178
|
};
|
|
@@ -181,6 +191,7 @@ var pool = async (items, limit, run) => {
|
|
|
181
191
|
return results;
|
|
182
192
|
};
|
|
183
193
|
var shootAll = async (options) => {
|
|
194
|
+
assertNoManagedFlags(options.args ?? []);
|
|
184
195
|
const screens = listScreens(options.command, options.args ?? []);
|
|
185
196
|
return pool(
|
|
186
197
|
screens,
|
|
@@ -189,4 +200,4 @@ var shootAll = async (options) => {
|
|
|
189
200
|
);
|
|
190
201
|
};
|
|
191
202
|
|
|
192
|
-
export { DEFAULT_FONT, capture, listScreens, shootAll, shootScreen, toImage };
|
|
203
|
+
export { DEFAULT_FONT, MANAGED_FLAGS, capture, listScreens, shootAll, shootScreen, toImage };
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { DEFAULT_FONT, listScreens, shootScreen, shootAll } from './chunk-
|
|
2
|
+
import { DEFAULT_FONT, listScreens, shootScreen, shootAll } from './chunk-NTFITNMX.js';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
|
|
5
5
|
var separator = process.argv.indexOf("--");
|
|
@@ -8,7 +8,7 @@ var own = separator === -1 ? process.argv : process.argv.slice(0, separator);
|
|
|
8
8
|
var program = new Command();
|
|
9
9
|
program.name("cli-shot").description(
|
|
10
10
|
"Screenshot an interactive CLI, one image per screen.\n\nThe command to drive follows `--`:\n cli-shot --out assets/screenshots -- pcloud"
|
|
11
|
-
).requiredOption("-o, --out <dir>", "directory to write PNGs into").option("
|
|
11
|
+
).requiredOption("-o, --out <dir>", "directory to write PNGs into").option("--only <screen>", "shoot one screen instead of every screen").option("--list", "print the screens the command offers, and stop").option("--cols <n>", "terminal columns", "110").option("--rows <n>", "terminal rows", "32").option("--settle <ms>", "how long the screen must hold still", "350").option("--keys <sequence>", "keystrokes to send once the screen has drawn").option(
|
|
12
12
|
"--font <family>",
|
|
13
13
|
"font to render with; needs Nerd Font coverage for TUI icons",
|
|
14
14
|
DEFAULT_FONT
|
|
@@ -37,5 +37,10 @@ if (options.list) {
|
|
|
37
37
|
console.log(listScreens(command, args).join("\n"));
|
|
38
38
|
process.exit(0);
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
try {
|
|
41
|
+
const written = options.only ? [await shootScreen(options.only, shoot)] : await shootAll(shoot);
|
|
42
|
+
for (const path of written) console.log(path);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,8 @@ type ShootOptions = CaptureOptions & RenderOptions & {
|
|
|
38
38
|
/** How many screens to shoot at once. Defaults to the core count. */
|
|
39
39
|
concurrency?: number;
|
|
40
40
|
};
|
|
41
|
+
declare const MANAGED_FLAGS: readonly ["--screen", "--mock"];
|
|
41
42
|
declare const shootScreen: (screen: string, { command, args, out, mock, ...rest }: ShootOptions) => Promise<string>;
|
|
42
43
|
declare const shootAll: (options: ShootOptions) => Promise<string[]>;
|
|
43
44
|
|
|
44
|
-
export { type CaptureOptions, DEFAULT_FONT, type RenderOptions, type ShootOptions, capture, listScreens, shootAll, shootScreen, toImage };
|
|
45
|
+
export { type CaptureOptions, DEFAULT_FONT, MANAGED_FLAGS, type RenderOptions, type ShootOptions, capture, listScreens, shootAll, shootScreen, toImage };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DEFAULT_FONT, capture, listScreens, shootAll, shootScreen, toImage } from './chunk-
|
|
1
|
+
export { DEFAULT_FONT, MANAGED_FLAGS, capture, listScreens, shootAll, shootScreen, toImage } from './chunk-NTFITNMX.js';
|