c456-cli 0.1.5 → 0.1.6

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.
Files changed (3) hide show
  1. package/README.md +1 -2
  2. package/dist/index.js +77 -39
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -87,7 +87,7 @@ c456 config show
87
87
 
88
88
  ```bash
89
89
  # 按 URL 创建 tool 收录(-B 为站点,-u 为收录目标)
90
- c456 -B https://c456.example.com intake new -k tool -u "https://github.com/owner/repo"
90
+ c456 -B https://c456.example.com intake new -k tool -u "https://github.com/owner/repo" --auto-resolve-url
91
91
 
92
92
  # 纯文本信号(可无 URL)
93
93
  c456 intake new -k signal -t "标题" -b "正文"
@@ -102,7 +102,6 @@ c456 intake delete <id> --force
102
102
 
103
103
  ```bash
104
104
  c456 fetch profile -u "https://..." -p link_product
105
- c456 fetch detect -u "https://..."
106
105
  ```
107
106
 
108
107
  ### 搜索(search)
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command as Command7 } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "c456-cli",
9
- version: "0.1.5",
9
+ version: "0.1.6",
10
10
  description: "C456 CLI - \u5185\u5BB9\u5F55\u5165\u4E0E\u6574\u7406\u5DE5\u5177",
11
11
  type: "module",
12
12
  bin: {
@@ -270,9 +270,22 @@ function resolveApi(cmd) {
270
270
  return { apiKey, baseUrl, client: new ApiClient(baseUrl, apiKey) };
271
271
  }
272
272
 
273
+ // src/textFile.js
274
+ import { readFileSync as readFileSync2 } from "node:fs";
275
+ function readTextFile(path) {
276
+ try {
277
+ return readFileSync2(path, "utf-8");
278
+ } catch (e) {
279
+ const msg = e instanceof Error ? e.message : String(e);
280
+ console.error(`\u9519\u8BEF\uFF1A\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6\uFF1A${path}`);
281
+ console.error(msg);
282
+ process.exit(1);
283
+ }
284
+ }
285
+
273
286
  // src/commands/intake.js
274
287
  var intake = new Command().name("intake").description("\u6536\u5F55\u7BA1\u7406 - \u521B\u5EFA\u3001\u66F4\u65B0\u3001\u5220\u9664\u5DE5\u5177/\u6E20\u9053/\u4FE1\u53F7");
275
- intake.command("new").description("\u521B\u5EFA\u65B0\u6536\u5F55").option("-u, --url <url>", "\u76EE\u6807 URL\uFF08tool/channel \u65F6\u53EF\u9009\uFF0C\u7528\u4E8E\u81EA\u52A8\u89E3\u6790\u8D44\u6599\uFF09").option("-k, --kind <type>", "\u7C7B\u578B\uFF1Asignal/tool/channel\uFF08\u9ED8\u8BA4 signal\uFF09", "signal").option("-t, --title <title>", "\u6807\u9898\uFF08tool/channel \u5FC5\u586B\uFF09").option("-b, --body <text>", "\u6B63\u6587/\u63CF\u8FF0\uFF08type: markdown_kramdown\uFF1B\u8BED\u6CD5\u89C1 references/content-syntax-kramdown.md\uFF09").option("--profile-data-json <json>", "\u8D44\u6599\u6BB5 JSON\uFF08tool/channel\uFF09").action(async (opts, cmd) => {
288
+ intake.command("new").description("\u521B\u5EFA\u65B0\u6536\u5F55").option("-u, --url <url>", "\u76EE\u6807 URL\uFF08tool/channel \u65F6\u53EF\u9009\uFF1B\u914D\u5408 --auto-resolve-url \u53EF\u81EA\u52A8\u89E3\u6790\u8D44\u6599\uFF09").option("-k, --kind <type>", "\u7C7B\u578B\uFF1Asignal/tool/channel\uFF08\u9ED8\u8BA4 signal\uFF09", "signal").option("-t, --title <title>", "\u6807\u9898\uFF08tool/channel \u5FC5\u586B\uFF09").option("-b, --body <text>", "\u6B63\u6587/\u63CF\u8FF0\uFF08\u4E0D\u63A8\u8350\u76F4\u63A5\u4F20\uFF1B\u8BF7\u7528 --body-file\uFF09").option("--body-file <path>", "\u6B63\u6587\u6587\u4EF6\u8DEF\u5F84\uFF08type: markdown_kramdown\uFF1B\u5EFA\u8BAE\u5199\u5230\u5F53\u524D\u76EE\u5F55 .tmp/\uFF09").option("--profile-data-json <json>", "\u8D44\u6599\u6BB5 JSON\uFF08tool/channel\uFF09").option("--auto-resolve-url", "\u81EA\u52A8\u89E3\u6790 URL \u5E76\u586B\u5145\u8D44\u6599\u6BB5 profile_data\uFF08\u4EC5 tool/channel\uFF1B\u4F1A\u53D1\u8D77\u7F51\u7EDC\u8BF7\u6C42\uFF09").action(async (opts, cmd) => {
276
289
  const { apiKey, baseUrl, client } = resolveApi(cmd);
277
290
  if (!apiKey) {
278
291
  console.error("\u9519\u8BEF\uFF1A\u672A\u914D\u7F6E API Key");
@@ -280,10 +293,15 @@ intake.command("new").description("\u521B\u5EFA\u65B0\u6536\u5F55").option("-u,
280
293
  process.exit(1);
281
294
  }
282
295
  try {
296
+ if (opts.body && opts.bodyFile) {
297
+ console.error("\u9519\u8BEF\uFF1A--body \u4E0E --body-file \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
298
+ process.exit(1);
299
+ }
300
+ const bodyText = opts.bodyFile ? readTextFile(opts.bodyFile) : opts.body || "";
283
301
  const body = {
284
302
  kind: opts.kind,
285
303
  title: opts.title || "",
286
- body: opts.body || ""
304
+ body: bodyText
287
305
  };
288
306
  if (opts.url) {
289
307
  body.url = opts.url;
@@ -291,6 +309,18 @@ intake.command("new").description("\u521B\u5EFA\u65B0\u6536\u5F55").option("-u,
291
309
  if (opts.profileDataJson) {
292
310
  body.profile_data_json = opts.profileDataJson;
293
311
  }
312
+ const kind = String(opts.kind ?? "signal");
313
+ if (opts.autoResolveUrl) {
314
+ if (!opts.url) {
315
+ console.error("\u9519\u8BEF\uFF1A\u4F7F\u7528 --auto-resolve-url \u65F6\u5FC5\u987B\u540C\u65F6\u63D0\u4F9B -u/--url");
316
+ process.exit(1);
317
+ }
318
+ if (kind !== "tool" && kind !== "channel") {
319
+ console.error("\u9519\u8BEF\uFF1A--auto-resolve-url \u4EC5\u9002\u7528\u4E8E -k tool \u6216 -k channel");
320
+ process.exit(1);
321
+ }
322
+ body.auto_resolve_url = true;
323
+ }
294
324
  const result = await client.post("/intakes", body);
295
325
  console.log("\u2705 \u6536\u5F55\u521B\u5EFA\u6210\u529F");
296
326
  console.log(` ID: ${result.data.id}`);
@@ -314,10 +344,10 @@ intake.command("new").description("\u521B\u5EFA\u65B0\u6536\u5F55").option("-u,
314
344
  const urlHint = Boolean(opts.url) && kind === "signal" && err instanceof ApiError && err.status === 422;
315
345
  if (urlHint) {
316
346
  console.error("");
317
- console.error("\u63D0\u793A\uFF1A\u5F53\u524D\u4E3A signal\uFF08\u9ED8\u8BA4\uFF09\u3002`-u` \u4EC5\u5728 `-k tool` \u6216 `-k channel` \u65F6\u4F1A\u7528\u4E8E\u81EA\u52A8\u89E3\u6790\u8D44\u6599\u3002");
347
+ console.error("\u63D0\u793A\uFF1A\u5F53\u524D\u4E3A signal\uFF08\u9ED8\u8BA4\uFF09\u3002\u82E5\u8981\u89E3\u6790 URL \u7684\u8D44\u6599\u6BB5\uFF0C\u8BF7\u4F7F\u7528 `-k tool`/`-k channel` \u5E76\u663E\u5F0F\u5F00\u542F `--auto-resolve-url`\u3002");
318
348
  console.error(" \u793A\u4F8B\uFF1A");
319
- console.error(' c456 -B <\u7AD9\u70B9> intake new -k channel -u "<\u9891\u9053\u6216\u4E3B\u9875 URL>"');
320
- console.error(' c456 -B <\u7AD9\u70B9> intake new -k tool -u "<\u5DE5\u5177 / \u4ED3\u5E93 URL>"');
349
+ console.error(' c456 -B <\u7AD9\u70B9> intake new -k channel -u "<\u9891\u9053\u6216\u4E3B\u9875 URL>" --auto-resolve-url');
350
+ console.error(' c456 -B <\u7AD9\u70B9> intake new -k tool -u "<\u5DE5\u5177 / \u4ED3\u5E93 URL>" --auto-resolve-url');
321
351
  }
322
352
  process.exit(1);
323
353
  }
@@ -343,7 +373,7 @@ intake.command("show").description("\u67E5\u770B\u6536\u5F55\u8BE6\u60C5").argum
343
373
  process.exit(1);
344
374
  }
345
375
  });
346
- intake.command("update").description("\u66F4\u65B0\u6536\u5F55").argument("<id>", "\u6536\u5F55 ID").option("-t, --title <title>", "\u65B0\u6807\u9898").option("-b, --body <text>", "\u65B0\u6B63\u6587\uFF08type: markdown_kramdown\uFF1B\u8BED\u6CD5\u89C1 references/content-syntax-kramdown.md\uFF09").option("--favorited", "\u6807\u8BB0\u4E3A\u6536\u85CF").option("--unfavorited", "\u53D6\u6D88\u6536\u85CF").action(async (id, opts, cmd) => {
376
+ intake.command("update").description("\u66F4\u65B0\u6536\u5F55").argument("<id>", "\u6536\u5F55 ID").option("-t, --title <title>", "\u65B0\u6807\u9898").option("-b, --body <text>", "\u65B0\u6B63\u6587\uFF08\u4E0D\u63A8\u8350\u76F4\u63A5\u4F20\uFF1B\u8BF7\u7528 --body-file\uFF09").option("--body-file <path>", "\u65B0\u6B63\u6587\u6587\u4EF6\u8DEF\u5F84\uFF08type: markdown_kramdown\uFF1B\u5EFA\u8BAE\u5199\u5230\u5F53\u524D\u76EE\u5F55 .tmp/\uFF09").option("--favorited", "\u6807\u8BB0\u4E3A\u6536\u85CF").option("--unfavorited", "\u53D6\u6D88\u6536\u85CF").action(async (id, opts, cmd) => {
347
377
  const { apiKey, client } = resolveApi(cmd);
348
378
  if (!apiKey) {
349
379
  console.error("\u9519\u8BEF\uFF1A\u672A\u914D\u7F6E API Key");
@@ -351,6 +381,11 @@ intake.command("update").description("\u66F4\u65B0\u6536\u5F55").argument("<id>"
351
381
  }
352
382
  const body = {};
353
383
  if (opts.title) body.title = opts.title;
384
+ if (opts.body && opts.bodyFile) {
385
+ console.error("\u9519\u8BEF\uFF1A--body \u4E0E --body-file \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
386
+ process.exit(1);
387
+ }
388
+ if (opts.bodyFile) body.body = readTextFile(opts.bodyFile);
354
389
  if (opts.body) body.body = opts.body;
355
390
  if (opts.favorited) body.favorited = true;
356
391
  if (opts.unfavorited) body.favorited = false;
@@ -453,29 +488,6 @@ fetchProfile.command("profile").description("\u6293\u53D6\u6307\u5B9A URL \u7684
453
488
  process.exit(1);
454
489
  }
455
490
  });
456
- fetchProfile.command("detect").description("\u521B\u5EFA tool \u6536\u5F55\u5E76\u5C1D\u8BD5\u81EA\u52A8\u89E3\u6790\u8D44\u6599\uFF08\u4E0D\u662F profile_id \u81EA\u52A8\u63A8\u65AD\uFF1B\u793E\u4EA4\u8D26\u53F7\u8BF7\u7528 fetch profile -p social_account\uFF09").requiredOption("-u, --url <url>", "\u76EE\u6807 URL").action(async (opts, cmd) => {
457
- const { apiKey, client } = resolveApi(cmd);
458
- if (!apiKey) {
459
- console.error("\u9519\u8BEF\uFF1A\u672A\u914D\u7F6E API Key");
460
- process.exit(1);
461
- }
462
- try {
463
- const result = await client.post("/intakes", {
464
- kind: "tool",
465
- url: opts.url
466
- });
467
- console.log("\u2705 \u81EA\u52A8\u68C0\u6D4B\u5E76\u6536\u5F55\u6210\u529F");
468
- console.log(`ID: ${result.data.id}`);
469
- console.log(`\u7C7B\u578B\uFF1A${result.data.kind}`);
470
- if (result.data.profileData) {
471
- console.log("\n\u89E3\u6790\u7684\u8D44\u6599\u6BB5\uFF1A");
472
- console.log(JSON.stringify(result.data.profileData, null, 2));
473
- }
474
- } catch (err) {
475
- console.error(`\u274C \u68C0\u6D4B\u5931\u8D25\uFF1A${err.message}`);
476
- process.exit(1);
477
- }
478
- });
479
491
  var fetch_default = fetchProfile;
480
492
 
481
493
  // src/commands/search.js
@@ -551,7 +563,7 @@ var search_default = searchCmd;
551
563
  // src/commands/playbook.js
552
564
  import { Command as Command4 } from "commander";
553
565
  var playbookCmd = new Command4().name("playbook").description("\u6253\u6CD5\u7BA1\u7406 - \u521B\u5EFA\u3001\u66F4\u65B0\u3001\u5220\u9664\u6253\u6CD5");
554
- playbookCmd.command("new").description("\u521B\u5EFA\u65B0\u6253\u6CD5").requiredOption("-t, --title <title>", "\u6253\u6CD5\u6807\u9898").option("-b, --body <text>", "\u6253\u6CD5\u6B63\u6587\uFF08type: markdown_kramdown\uFF1B\u8BED\u6CD5\u89C1 references/content-syntax-kramdown.md\uFF09").option("--ref-intake <id>", "\u5F15\u7528\u6536\u5F55 ID\uFF08\u53EF\u591A\u6B21\u6307\u5B9A\uFF09").option("--ref-playbook <id>", "\u5F15\u7528\u6253\u6CD5 ID\uFF08\u53EF\u591A\u6B21\u6307\u5B9A\uFF09").action(async (opts, cmd) => {
566
+ playbookCmd.command("new").description("\u521B\u5EFA\u65B0\u6253\u6CD5").requiredOption("-t, --title <title>", "\u6253\u6CD5\u6807\u9898").option("-b, --body <text>", "\u6253\u6CD5\u6B63\u6587\uFF08\u4E0D\u63A8\u8350\u76F4\u63A5\u4F20\uFF1B\u8BF7\u7528 --body-file\uFF09").option("--body-file <path>", "\u6253\u6CD5\u6B63\u6587\u6587\u4EF6\u8DEF\u5F84\uFF08type: markdown_kramdown\uFF1B\u5EFA\u8BAE\u5199\u5230\u5F53\u524D\u76EE\u5F55 .tmp/\uFF09").option("--ref-intake <id>", "\u5F15\u7528\u6536\u5F55 ID\uFF08\u53EF\u591A\u6B21\u6307\u5B9A\uFF09").option("--ref-playbook <id>", "\u5F15\u7528\u6253\u6CD5 ID\uFF08\u53EF\u591A\u6B21\u6307\u5B9A\uFF09").action(async (opts, cmd) => {
555
567
  const { apiKey, client } = resolveApi(cmd);
556
568
  if (!apiKey) {
557
569
  console.error("\u9519\u8BEF\uFF1A\u672A\u914D\u7F6E API Key");
@@ -571,9 +583,14 @@ playbookCmd.command("new").description("\u521B\u5EFA\u65B0\u6253\u6CD5").require
571
583
  });
572
584
  }
573
585
  try {
586
+ if (opts.body && opts.bodyFile) {
587
+ console.error("\u9519\u8BEF\uFF1A--body \u4E0E --body-file \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
588
+ process.exit(1);
589
+ }
590
+ const bodyText = opts.bodyFile ? readTextFile(opts.bodyFile) : opts.body || "";
574
591
  const body = {
575
592
  title: opts.title,
576
- body: opts.body || ""
593
+ body: bodyText
577
594
  };
578
595
  if (referenceTargets.length > 0) {
579
596
  body.reference_targets = referenceTargets;
@@ -617,7 +634,7 @@ ${data.body || "(\u65E0)"}`);
617
634
  process.exit(1);
618
635
  }
619
636
  });
620
- playbookCmd.command("update").description("\u66F4\u65B0\u6253\u6CD5").argument("<id>", "\u6253\u6CD5 ID").option("-t, --title <title>", "\u65B0\u6807\u9898").option("-b, --body <text>", "\u65B0\u6B63\u6587\uFF08type: markdown_kramdown\uFF1B\u8BED\u6CD5\u89C1 references/content-syntax-kramdown.md\uFF09").action(async (id, opts, cmd) => {
637
+ playbookCmd.command("update").description("\u66F4\u65B0\u6253\u6CD5").argument("<id>", "\u6253\u6CD5 ID").option("-t, --title <title>", "\u65B0\u6807\u9898").option("-b, --body <text>", "\u65B0\u6B63\u6587\uFF08\u4E0D\u63A8\u8350\u76F4\u63A5\u4F20\uFF1B\u8BF7\u7528 --body-file\uFF09").option("--body-file <path>", "\u65B0\u6B63\u6587\u6587\u4EF6\u8DEF\u5F84\uFF08type: markdown_kramdown\uFF1B\u5EFA\u8BAE\u5199\u5230\u5F53\u524D\u76EE\u5F55 .tmp/\uFF09").action(async (id, opts, cmd) => {
621
638
  const { apiKey, client } = resolveApi(cmd);
622
639
  if (!apiKey) {
623
640
  console.error("\u9519\u8BEF\uFF1A\u672A\u914D\u7F6E API Key");
@@ -625,6 +642,11 @@ playbookCmd.command("update").description("\u66F4\u65B0\u6253\u6CD5").argument("
625
642
  }
626
643
  const body = {};
627
644
  if (opts.title) body.title = opts.title;
645
+ if (opts.body && opts.bodyFile) {
646
+ console.error("\u9519\u8BEF\uFF1A--body \u4E0E --body-file \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
647
+ process.exit(1);
648
+ }
649
+ if (opts.bodyFile) body.body = readTextFile(opts.bodyFile);
628
650
  if (opts.body) body.body = opts.body;
629
651
  try {
630
652
  await client.patch(`/playbooks/${id}`, body);
@@ -720,15 +742,23 @@ function buildWalkthroughFields(opts) {
720
742
  if (opts.publicationStatus !== void 0) w.publication_status = opts.publicationStatus;
721
743
  return w;
722
744
  }
723
- walkthroughCmd.command("new").description("\u521B\u5EFA\u65B0\u8BB2\u89E3").requiredOption("-t, --title <title>", "\u6807\u9898").option("-s, --summary <text>", "\u6458\u8981").option("-b, --body <text>", "\u6B63\u6587\uFF08type: markdown_kramdown\uFF1B\u8BED\u6CD5\u89C1 references/content-syntax-kramdown.md\uFF09").option("--source-kind <kind>", "\u6765\u6E90\uFF1Aupload/external_url\uFF08\u9ED8\u8BA4 upload\uFF09", "upload").option("--external-url <url>", "asciinema.org \u94FE\u63A5\uFF08source-kind=external_url \u65F6\u5FC5\u586B\uFF09").option("--cast-file <path>", ".cast \u6587\u4EF6\u8DEF\u5F84\uFF08source-kind=upload \u65F6\u5FC5\u586B\uFF09").option("--poster-at <seconds>", "\u5C01\u9762\u9884\u89C8\u79D2\u6570\uFF08>=0 \u7684\u6574\u6570\uFF09").action(async (opts, cmd) => {
745
+ walkthroughCmd.command("new").description("\u521B\u5EFA\u65B0\u8BB2\u89E3").requiredOption("-t, --title <title>", "\u6807\u9898").option("-s, --summary <text>", "\u6458\u8981\uFF08\u4E0D\u63A8\u8350\u76F4\u63A5\u4F20\uFF1B\u8BF7\u7528 --summary-file\uFF09").option("--summary-file <path>", "\u6458\u8981\u6587\u4EF6\u8DEF\u5F84\uFF08\u5EFA\u8BAE\u5199\u5230\u5F53\u524D\u76EE\u5F55 .tmp/\uFF09").option("-b, --body <text>", "\u6B63\u6587\uFF08\u4E0D\u63A8\u8350\u76F4\u63A5\u4F20\uFF1B\u8BF7\u7528 --body-file\uFF09").option("--body-file <path>", "\u6B63\u6587\u6587\u4EF6\u8DEF\u5F84\uFF08type: markdown_kramdown\uFF1B\u5EFA\u8BAE\u5199\u5230\u5F53\u524D\u76EE\u5F55 .tmp/\uFF09").option("--source-kind <kind>", "\u6765\u6E90\uFF1Aupload/external_url\uFF08\u9ED8\u8BA4 upload\uFF09", "upload").option("--external-url <url>", "asciinema.org \u94FE\u63A5\uFF08source-kind=external_url \u65F6\u5FC5\u586B\uFF09").option("--cast-file <path>", ".cast \u6587\u4EF6\u8DEF\u5F84\uFF08source-kind=upload \u65F6\u5FC5\u586B\uFF09").option("--poster-at <seconds>", "\u5C01\u9762\u9884\u89C8\u79D2\u6570\uFF08>=0 \u7684\u6574\u6570\uFF09").action(async (opts, cmd) => {
724
746
  const { apiKey, client } = resolveApi(cmd);
725
747
  requireApiKey(apiKey);
726
748
  const sourceKind = ensureSourceKind(opts.sourceKind);
727
749
  const posterAt = opts.posterAt !== void 0 ? Number.parseInt(String(opts.posterAt), 10) : void 0;
750
+ if (opts.body && opts.bodyFile) {
751
+ console.error("\u9519\u8BEF\uFF1A--body \u4E0E --body-file \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
752
+ process.exit(1);
753
+ }
754
+ if (opts.summary && opts.summaryFile) {
755
+ console.error("\u9519\u8BEF\uFF1A--summary \u4E0E --summary-file \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
756
+ process.exit(1);
757
+ }
728
758
  const w = {
729
759
  title: opts.title,
730
- summary: opts.summary || "",
731
- body: opts.body || "",
760
+ summary: opts.summaryFile ? readTextFile(opts.summaryFile) : opts.summary || "",
761
+ body: opts.bodyFile ? readTextFile(opts.bodyFile) : opts.body || "",
732
762
  source_kind: sourceKind,
733
763
  external_url: opts.externalUrl || "",
734
764
  poster_preview_at_seconds: Number.isFinite(posterAt) ? posterAt : void 0
@@ -799,14 +829,22 @@ ${w.body || "(\u65E0)"}`);
799
829
  console.log(`\u6765\u6E90\uFF1A${w.sourceKind}`);
800
830
  if (w.src) console.log(`\u5A92\u4F53\uFF1A${w.src}`);
801
831
  });
802
- walkthroughCmd.command("update").description("\u66F4\u65B0\u8BB2\u89E3").argument("<id>", "\u8BB2\u89E3 ID").option("-t, --title <title>", "\u65B0\u6807\u9898").option("-s, --summary <text>", "\u65B0\u6458\u8981").option("-b, --body <text>", "\u65B0\u6B63\u6587\uFF08type: markdown_kramdown\uFF1B\u8BED\u6CD5\u89C1 references/content-syntax-kramdown.md\uFF09").option("--publication-status <status>", "\u53D1\u5E03\u72B6\u6001\uFF1Apending_review/private").option("--source-kind <kind>", "\u6765\u6E90\uFF1Aupload/external_url").option("--external-url <url>", "asciinema.org \u94FE\u63A5\uFF08source-kind=external_url\uFF09").option("--cast-file <path>", ".cast \u6587\u4EF6\u8DEF\u5F84\uFF08\u4E0A\u4F20\u66FF\u6362\uFF09").option("--poster-at <seconds>", "\u5C01\u9762\u9884\u89C8\u79D2\u6570\uFF08>=0 \u7684\u6574\u6570\uFF09").action(async (id, opts, cmd) => {
832
+ walkthroughCmd.command("update").description("\u66F4\u65B0\u8BB2\u89E3").argument("<id>", "\u8BB2\u89E3 ID").option("-t, --title <title>", "\u65B0\u6807\u9898").option("-s, --summary <text>", "\u65B0\u6458\u8981\uFF08\u4E0D\u63A8\u8350\u76F4\u63A5\u4F20\uFF1B\u8BF7\u7528 --summary-file\uFF09").option("--summary-file <path>", "\u65B0\u6458\u8981\u6587\u4EF6\u8DEF\u5F84\uFF08\u5EFA\u8BAE\u5199\u5230\u5F53\u524D\u76EE\u5F55 .tmp/\uFF09").option("-b, --body <text>", "\u65B0\u6B63\u6587\uFF08\u4E0D\u63A8\u8350\u76F4\u63A5\u4F20\uFF1B\u8BF7\u7528 --body-file\uFF09").option("--body-file <path>", "\u65B0\u6B63\u6587\u6587\u4EF6\u8DEF\u5F84\uFF08type: markdown_kramdown\uFF1B\u5EFA\u8BAE\u5199\u5230\u5F53\u524D\u76EE\u5F55 .tmp/\uFF09").option("--publication-status <status>", "\u53D1\u5E03\u72B6\u6001\uFF1Apending_review/private").option("--source-kind <kind>", "\u6765\u6E90\uFF1Aupload/external_url").option("--external-url <url>", "asciinema.org \u94FE\u63A5\uFF08source-kind=external_url\uFF09").option("--cast-file <path>", ".cast \u6587\u4EF6\u8DEF\u5F84\uFF08\u4E0A\u4F20\u66FF\u6362\uFF09").option("--poster-at <seconds>", "\u5C01\u9762\u9884\u89C8\u79D2\u6570\uFF08>=0 \u7684\u6574\u6570\uFF09").action(async (id, opts, cmd) => {
803
833
  const { apiKey, client } = resolveApi(cmd);
804
834
  requireApiKey(apiKey);
805
835
  const posterAt = opts.posterAt !== void 0 ? Number.parseInt(String(opts.posterAt), 10) : void 0;
836
+ if (opts.body && opts.bodyFile) {
837
+ console.error("\u9519\u8BEF\uFF1A--body \u4E0E --body-file \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
838
+ process.exit(1);
839
+ }
840
+ if (opts.summary && opts.summaryFile) {
841
+ console.error("\u9519\u8BEF\uFF1A--summary \u4E0E --summary-file \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
842
+ process.exit(1);
843
+ }
806
844
  const w = buildWalkthroughFields({
807
845
  title: opts.title,
808
- summary: opts.summary,
809
- body: opts.body,
846
+ summary: opts.summaryFile ? readTextFile(opts.summaryFile) : opts.summary,
847
+ body: opts.bodyFile ? readTextFile(opts.bodyFile) : opts.body,
810
848
  sourceKind: opts.sourceKind ? ensureSourceKind(opts.sourceKind) : void 0,
811
849
  externalUrl: opts.externalUrl,
812
850
  posterAt: Number.isFinite(posterAt) ? posterAt : void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c456-cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "C456 CLI - 内容录入与整理工具",
5
5
  "type": "module",
6
6
  "bin": {