@kaynooo/cli-edit 0.10.0 → 0.10.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/dist/cli.js +6 -11
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -367,18 +367,14 @@ var FULL_STOP = /\.$/;
|
|
|
367
367
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
368
368
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
369
369
|
}
|
|
370
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
371
|
-
return [usageLine(usage, colors),
|
|
370
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
371
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
372
372
|
`);
|
|
373
373
|
}
|
|
374
374
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
375
375
|
if (exits.length === 0)
|
|
376
376
|
return [];
|
|
377
|
-
|
|
378
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
379
|
-
}
|
|
380
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
381
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
377
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
382
378
|
}
|
|
383
379
|
function wantsHelpJson(env = process8.env) {
|
|
384
380
|
return env.KIT_HELP === "json";
|
|
@@ -1066,9 +1062,8 @@ new lines
|
|
|
1066
1062
|
>>>>>>> REPLACE
|
|
1067
1063
|
EOF
|
|
1068
1064
|
|
|
1069
|
-
A line naming a file before a block makes it apply to that file alone, so one call edits several files (no file argument needed when every block names one). An empty REPLACE deletes the SEARCH text; to drop whole lines, put the neighbouring line in both. When the text holds a marker line itself (a Markdown '=======' underline), open with more characters, '<<<<<<<<<< SEARCH', and divide and close with as many '=' and '>' too
|
|
1070
|
-
|
|
1071
|
-
Exits 0 when it wrote every replacement, 1 when one did not match or a file cannot be written (nothing is written), 2 on a usage error.`;
|
|
1065
|
+
A line naming a file before a block makes it apply to that file alone, so one call edits several files (no file argument needed when every block names one). An empty REPLACE deletes the SEARCH text; to drop whole lines, put the neighbouring line in both. When the text holds a marker line itself (a Markdown '=======' underline), open with more characters, '<<<<<<<<<< SEARCH', and divide and close with as many '=' and '>' too.`;
|
|
1066
|
+
var EXITS = [[0, "it wrote every replacement"], [1, "one did not match or a file cannot be written (nothing is written)"], [2, "a usage error"]];
|
|
1072
1067
|
var OPTIONS = {
|
|
1073
1068
|
from: { type: "string", short: "f", description: "text to find, taken literally" },
|
|
1074
1069
|
to: { type: "string", short: "t", description: "text to put in its place, empty to delete it" },
|
|
@@ -1246,7 +1241,7 @@ ${USAGE}`);
|
|
|
1246
1241
|
return edits;
|
|
1247
1242
|
}
|
|
1248
1243
|
async function main(argv) {
|
|
1249
|
-
const parsed = parse(argv, USAGE, OPTIONS, { replaces: "sed -i and one-off bun -e or python editors", examples: [["sub src/a.php <<'EOF' (SEARCH/REPLACE blocks, see above)", "multi-line text, no escaping"], ["sub --from oldName --to newName --all src/a.ts src/b.ts", "every match in two files"], ['sub --regex --from "v(\\d+)" --to "v$1.0" --dry-run --diff README.md', "the diff, nothing written"]] });
|
|
1244
|
+
const parsed = parse(argv, USAGE, OPTIONS, { exits: EXITS, replaces: "sed -i and one-off bun -e or python editors", examples: [["sub src/a.php <<'EOF' (SEARCH/REPLACE blocks, see above)", "multi-line text, no escaping"], ["sub --from oldName --to newName --all src/a.ts src/b.ts", "every match in two files"], ['sub --regex --from "v(\\d+)" --to "v$1.0" --dry-run --diff README.md', "the diff, nothing written"]] });
|
|
1250
1245
|
const { values, positionals } = parsed;
|
|
1251
1246
|
const files = dedupe(positionals.map((path) => normalize(path)));
|
|
1252
1247
|
if (values.count !== undefined && values.all === true)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-edit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.1",
|
|
5
5
|
"description": "sub: text replaced in files for Claude Code, written only when every replacement matches as often as expected.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|