@kaynooo/cli-edit 0.5.1 → 0.6.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 CHANGED
@@ -32,6 +32,6 @@ EOF
32
32
  - When the text holds a marker line itself (a Markdown `=======` underline), open with more characters, `<<<<<<<<<< SEARCH`, and divide and close with as many `=` and `>`.
33
33
  - `--pairs <json|file>` (or `-` for stdin) applies a JSON array of `{ "from", "to", "count"?, "all"?, "regex"? }` in order, each on the previous one's result, all or nothing; a value starting with `[` is the JSON itself, any other key in a pair is refused. `--count`, `--all` and `--regex` are the defaults of pairs that do not set them.
34
34
  - A file with CRLF endings matches a literal `--from` typed with plain newlines, and the replacement keeps CRLF.
35
- - Each written file prints `<path>: N replacements on lines L, +added -removed`; `--diff` adds its unified diff (through the system's `diff`), `--dry-run` shows the same without writing.
35
+ - `--quiet` prints nothing on success. Each written file prints `<path>: N replacements on lines L, +added -removed`; `--diff` adds its unified diff (through the system's `diff`), `--dry-run` shows the same without writing.
36
36
  - The file is rewritten in place, so its mode, owner and missing trailing newline stay.
37
37
  - Exit codes: 0 written, 1 a replacement did not match as expected, 2 a usage error.
package/dist/cli.js CHANGED
@@ -703,7 +703,7 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
703
703
  const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
704
704
  const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
705
705
  const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
706
- if (error instanceof UsageError)
706
+ if (error instanceof Exit && error.code === 2)
707
707
  noteUsageError(error.message);
708
708
  const report = json ? printJsonError : (message, hint, causeText) => printError(prefix, message, hint, causeText);
709
709
  report(redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
@@ -989,6 +989,7 @@ var OPTIONS = {
989
989
  pairs: { type: "string", short: "p", description: "JSON array of {from, to, count?, all?, regex?} applied in order: inline when it starts with [, else a file or - for stdin" },
990
990
  diff: { type: "boolean", short: "d", description: "print each file's unified diff" },
991
991
  "dry-run": { type: "boolean", description: "show what would change without writing" },
992
+ quiet: { type: "boolean", short: "q", description: "print nothing on success, the diff aside" },
992
993
  json: jsonOption("{dryRun, files: [{path, replacements, lines, added, removed, diff?}]}, or {error, failures: [{path, problem}]} on stderr when nothing is written")
993
994
  };
994
995
  var PAIR_KEYS = ["from", "to", "count", "all", "regex"];
@@ -1183,13 +1184,14 @@ ${error instanceof Error ? error.message : String(error)}`);
1183
1184
  done.push({ path, replacements: lines.length, lines, added: diff.added, removed: diff.removed, ...values.diff === true ? { diff: diff.unified } : {} });
1184
1185
  continue;
1185
1186
  }
1186
- console.log(`${path}: ${plural(lines.length, "replacement")} on line${lines.length === 1 ? "" : "s"} ${listLines(lines)}, +${diff.added} -${diff.removed}`);
1187
+ if (values.quiet !== true)
1188
+ console.log(`${path}: ${plural(lines.length, "replacement")} on line${lines.length === 1 ? "" : "s"} ${listLines(lines)}, +${diff.added} -${diff.removed}`);
1187
1189
  if (values.diff === true && diff.unified !== "")
1188
1190
  process9.stdout.write(diff.unified);
1189
1191
  }
1190
1192
  if (json)
1191
1193
  printJson({ dryRun: values["dry-run"] === true, files: done });
1192
- else if (values["dry-run"] === true)
1194
+ else if (values["dry-run"] === true && values.quiet !== true)
1193
1195
  console.log("dry run: nothing written");
1194
1196
  return 0;
1195
1197
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-edit",
3
3
  "type": "module",
4
- "version": "0.5.1",
4
+ "version": "0.6.0",
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",
@@ -36,6 +36,6 @@
36
36
  "sub": "$npm_execpath src/cli.ts"
37
37
  },
38
38
  "devDependencies": {
39
- "@kaynooo/cli-kit": "0.21.0"
39
+ "@kaynooo/cli-kit": "0.21.1"
40
40
  }
41
41
  }