@hawkeyexl/manni 2.3.10 → 2.4.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.
@@ -61,7 +61,7 @@ import {
61
61
  supportedExtensions,
62
62
  terminalConfirm,
63
63
  toJsonText
64
- } from "./chunk-TNT3ZROC.js";
64
+ } from "./chunk-LYLNOJ32.js";
65
65
 
66
66
  // src/meta/cli.ts
67
67
  import { existsSync } from "node:fs";
@@ -1517,4 +1517,4 @@ export {
1517
1517
  reportConfig,
1518
1518
  buildProgram
1519
1519
  };
1520
- //# sourceMappingURL=chunk-WXBLVCOZ.js.map
1520
+ //# sourceMappingURL=chunk-Z2PBY6LN.js.map
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  readStdin,
8
8
  reportConfig,
9
9
  splitList
10
- } from "./chunk-WXBLVCOZ.js";
10
+ } from "./chunk-Z2PBY6LN.js";
11
11
  import {
12
12
  CiteError,
13
13
  KeyError,
@@ -25,19 +25,22 @@ import {
25
25
  renderCheckGithub,
26
26
  renderCheckJson,
27
27
  renderCheckPretty,
28
+ renderRemoveJson,
29
+ renderRemovePretty,
28
30
  renderUpdateJson,
29
31
  renderUpdatePretty,
30
32
  runAdd,
31
33
  runCheck,
32
34
  runKeyRotate,
33
35
  runKeySet,
36
+ runRemove,
34
37
  runUpdate,
35
38
  shortCommit,
36
39
  shortLine,
37
40
  shortPin,
38
41
  shortSrc,
39
42
  spellSource
40
- } from "./chunk-LORLZO3J.js";
43
+ } from "./chunk-P4KR3XFD.js";
41
44
  import {
42
45
  COMMON_FORMAT_LIST,
43
46
  OMITTED_WHEN_CLEAN,
@@ -75,7 +78,7 @@ import {
75
78
  splitPageArgument,
76
79
  terminalConfirm,
77
80
  valeConfigPath
78
- } from "./chunk-TNT3ZROC.js";
81
+ } from "./chunk-LYLNOJ32.js";
79
82
 
80
83
  // src/cli.ts
81
84
  import { Command as Command5 } from "commander";
@@ -1057,6 +1060,7 @@ function renderCheckJunit(run) {
1057
1060
 
1058
1061
  // src/cite/cli.ts
1059
1062
  var UPDATE_FORMATS = ["pretty", "json"];
1063
+ var REMOVE_FORMATS = UPDATE_FORMATS;
1060
1064
  function colorFor(command, isTTY, env) {
1061
1065
  const noColor = colorOwner(command).opts().color === false;
1062
1066
  return shouldColor({ noColor, isTTY, env });
@@ -1070,6 +1074,9 @@ function colorOwner(command) {
1070
1074
  function isUpdateFormat(value) {
1071
1075
  return UPDATE_FORMATS.includes(value);
1072
1076
  }
1077
+ function isRemoveFormat(value) {
1078
+ return REMOVE_FORMATS.includes(value);
1079
+ }
1073
1080
  function splitPageArgument2(arg) {
1074
1081
  return asCiteError(() => splitPageArgument(arg));
1075
1082
  }
@@ -1358,6 +1365,82 @@ function buildProgram3() {
1358
1365
  fail(err);
1359
1366
  }
1360
1367
  });
1368
+ program.command("remove").description("Remove the named citations from the given pages, markers and all").argument(
1369
+ "[paths...]",
1370
+ "files, directories, or globs to remove from (use - for stdin)"
1371
+ ).option(
1372
+ "--collection <name>",
1373
+ "configured collection to run over; repeatable",
1374
+ collect,
1375
+ []
1376
+ ).option("--ext <list>", "comma-separated extensions for directory walks").option("--exclude <glob>", "glob to exclude; repeatable", collect, []).option("--as <format>", "force an input format for every input").option("-c, --config <path>", "path to a manni config file").option("--no-config", "ignore any discovered config file").option("--allow-empty", "treat zero matched files as success").option("--no-gitignore", "remove from files .gitignore covers").option(
1377
+ "--only <id>",
1378
+ "the entry to remove, by id or by pointer (/citations/N); required, and repeatable",
1379
+ collect,
1380
+ []
1381
+ ).option("--dry-run", "print the diffs and the report; write nothing").option(
1382
+ "-f, --format <format>",
1383
+ `output: ${REMOVE_FORMATS.join(" | ")}`,
1384
+ "pretty"
1385
+ ).addHelpText(
1386
+ "after",
1387
+ [
1388
+ "",
1389
+ "Examples:",
1390
+ " manni cite remove docs/limits.md --only fetch-timeout",
1391
+ " manni cite remove docs/ --only fetch-timeout --only retries --dry-run",
1392
+ " manni cite remove --collection site --only /citations/3 -f json"
1393
+ ].join("\n")
1394
+ ).action(async (paths, options, command) => {
1395
+ try {
1396
+ const format = options.format;
1397
+ if (!isRemoveFormat(format)) {
1398
+ throw new CiteError(
1399
+ `Unknown --format "${format}". Use ${COMMON_FORMAT_LIST}.`
1400
+ );
1401
+ }
1402
+ const exts = options.ext ? splitList(options.ext) : void 0;
1403
+ const usingStdin = paths.includes(STDIN_TOKEN);
1404
+ const stdinContent = usingStdin ? await readStdin() : void 0;
1405
+ const dryRun = Boolean(options.dryRun);
1406
+ const pageToStdout = usingStdin && !dryRun;
1407
+ const cwd = process.cwd();
1408
+ const run = await runRemove({
1409
+ inputs: paths,
1410
+ collection: options.collection,
1411
+ exts,
1412
+ exclude: options.exclude,
1413
+ as: options.as,
1414
+ ...configOption(options.config),
1415
+ onConfigLoaded: reportConfig(format === "pretty" && !pageToStdout, cwd),
1416
+ stdinContent,
1417
+ allowEmpty: options.allowEmpty ? true : void 0,
1418
+ respectGitignore: explicitFalse(options.gitignore),
1419
+ onNotice: notice,
1420
+ only: options.only,
1421
+ dryRun
1422
+ });
1423
+ const text2 = format === "json" ? renderRemoveJson(run) : renderRemovePretty(run, {
1424
+ color: colorFor(command, process.stdout.isTTY),
1425
+ // The diffs are the point of a dry run; a real run prints
1426
+ // what it removed and leaves the file to say the rest.
1427
+ showDiff: dryRun,
1428
+ dryRun
1429
+ });
1430
+ const stdinPage = pageToStdout ? run.pages.find((page) => page.content !== void 0) : void 0;
1431
+ if (stdinPage?.content !== void 0) {
1432
+ process.stdout.write(stdinPage.content);
1433
+ process.stderr.write(`${text2}
1434
+ `);
1435
+ } else {
1436
+ process.stdout.write(`${text2}
1437
+ `);
1438
+ }
1439
+ process.exitCode = 0;
1440
+ } catch (err) {
1441
+ fail(err);
1442
+ }
1443
+ });
1361
1444
  return program;
1362
1445
  }
1363
1446