c456-cli 0.1.4 → 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.
- package/README.md +1 -2
- package/dist/index.js +88 -40
- 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.
|
|
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\
|
|
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:
|
|
304
|
+
body: bodyText
|
|
287
305
|
};
|
|
288
306
|
if (opts.url) {
|
|
289
307
|
body.url = opts.url;
|
|
@@ -291,23 +309,45 @@ 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}`);
|
|
297
327
|
console.log(` \u7C7B\u578B\uFF1A${result.data.kind}`);
|
|
298
328
|
console.log(` \u6807\u9898\uFF1A${result.data.title || "(\u65E0)"}`);
|
|
299
329
|
console.log("\n--- JSON ---");
|
|
300
|
-
console.log(
|
|
330
|
+
console.log(
|
|
331
|
+
JSON.stringify(
|
|
332
|
+
{
|
|
333
|
+
id: result.data.id,
|
|
334
|
+
kind: result.data.kind,
|
|
335
|
+
title: result.data.title || ""
|
|
336
|
+
},
|
|
337
|
+
null,
|
|
338
|
+
2
|
|
339
|
+
)
|
|
340
|
+
);
|
|
301
341
|
} catch (err) {
|
|
302
342
|
console.error(`\u274C \u521B\u5EFA\u5931\u8D25\uFF1A${err.message}`);
|
|
303
343
|
const kind = String(opts.kind ?? "signal");
|
|
304
344
|
const urlHint = Boolean(opts.url) && kind === "signal" && err instanceof ApiError && err.status === 422;
|
|
305
345
|
if (urlHint) {
|
|
306
346
|
console.error("");
|
|
307
|
-
console.error("\u63D0\u793A\uFF1A\u5F53\u524D\u4E3A signal\uFF08\u9ED8\u8BA4\uFF09\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");
|
|
308
348
|
console.error(" \u793A\u4F8B\uFF1A");
|
|
309
|
-
console.error(' c456 -B <\u7AD9\u70B9> intake new -k channel -u "<\u9891\u9053\u6216\u4E3B\u9875 URL>"');
|
|
310
|
-
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');
|
|
311
351
|
}
|
|
312
352
|
process.exit(1);
|
|
313
353
|
}
|
|
@@ -333,7 +373,7 @@ intake.command("show").description("\u67E5\u770B\u6536\u5F55\u8BE6\u60C5").argum
|
|
|
333
373
|
process.exit(1);
|
|
334
374
|
}
|
|
335
375
|
});
|
|
336
|
-
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\
|
|
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) => {
|
|
337
377
|
const { apiKey, client } = resolveApi(cmd);
|
|
338
378
|
if (!apiKey) {
|
|
339
379
|
console.error("\u9519\u8BEF\uFF1A\u672A\u914D\u7F6E API Key");
|
|
@@ -341,6 +381,11 @@ intake.command("update").description("\u66F4\u65B0\u6536\u5F55").argument("<id>"
|
|
|
341
381
|
}
|
|
342
382
|
const body = {};
|
|
343
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);
|
|
344
389
|
if (opts.body) body.body = opts.body;
|
|
345
390
|
if (opts.favorited) body.favorited = true;
|
|
346
391
|
if (opts.unfavorited) body.favorited = false;
|
|
@@ -443,29 +488,6 @@ fetchProfile.command("profile").description("\u6293\u53D6\u6307\u5B9A URL \u7684
|
|
|
443
488
|
process.exit(1);
|
|
444
489
|
}
|
|
445
490
|
});
|
|
446
|
-
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) => {
|
|
447
|
-
const { apiKey, client } = resolveApi(cmd);
|
|
448
|
-
if (!apiKey) {
|
|
449
|
-
console.error("\u9519\u8BEF\uFF1A\u672A\u914D\u7F6E API Key");
|
|
450
|
-
process.exit(1);
|
|
451
|
-
}
|
|
452
|
-
try {
|
|
453
|
-
const result = await client.post("/intakes", {
|
|
454
|
-
kind: "tool",
|
|
455
|
-
url: opts.url
|
|
456
|
-
});
|
|
457
|
-
console.log("\u2705 \u81EA\u52A8\u68C0\u6D4B\u5E76\u6536\u5F55\u6210\u529F");
|
|
458
|
-
console.log(`ID: ${result.data.id}`);
|
|
459
|
-
console.log(`\u7C7B\u578B\uFF1A${result.data.kind}`);
|
|
460
|
-
if (result.data.profileData) {
|
|
461
|
-
console.log("\n\u89E3\u6790\u7684\u8D44\u6599\u6BB5\uFF1A");
|
|
462
|
-
console.log(JSON.stringify(result.data.profileData, null, 2));
|
|
463
|
-
}
|
|
464
|
-
} catch (err) {
|
|
465
|
-
console.error(`\u274C \u68C0\u6D4B\u5931\u8D25\uFF1A${err.message}`);
|
|
466
|
-
process.exit(1);
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
491
|
var fetch_default = fetchProfile;
|
|
470
492
|
|
|
471
493
|
// src/commands/search.js
|
|
@@ -541,7 +563,7 @@ var search_default = searchCmd;
|
|
|
541
563
|
// src/commands/playbook.js
|
|
542
564
|
import { Command as Command4 } from "commander";
|
|
543
565
|
var playbookCmd = new Command4().name("playbook").description("\u6253\u6CD5\u7BA1\u7406 - \u521B\u5EFA\u3001\u66F4\u65B0\u3001\u5220\u9664\u6253\u6CD5");
|
|
544
|
-
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\
|
|
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) => {
|
|
545
567
|
const { apiKey, client } = resolveApi(cmd);
|
|
546
568
|
if (!apiKey) {
|
|
547
569
|
console.error("\u9519\u8BEF\uFF1A\u672A\u914D\u7F6E API Key");
|
|
@@ -561,9 +583,14 @@ playbookCmd.command("new").description("\u521B\u5EFA\u65B0\u6253\u6CD5").require
|
|
|
561
583
|
});
|
|
562
584
|
}
|
|
563
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 || "";
|
|
564
591
|
const body = {
|
|
565
592
|
title: opts.title,
|
|
566
|
-
body:
|
|
593
|
+
body: bodyText
|
|
567
594
|
};
|
|
568
595
|
if (referenceTargets.length > 0) {
|
|
569
596
|
body.reference_targets = referenceTargets;
|
|
@@ -607,7 +634,7 @@ ${data.body || "(\u65E0)"}`);
|
|
|
607
634
|
process.exit(1);
|
|
608
635
|
}
|
|
609
636
|
});
|
|
610
|
-
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\
|
|
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) => {
|
|
611
638
|
const { apiKey, client } = resolveApi(cmd);
|
|
612
639
|
if (!apiKey) {
|
|
613
640
|
console.error("\u9519\u8BEF\uFF1A\u672A\u914D\u7F6E API Key");
|
|
@@ -615,6 +642,11 @@ playbookCmd.command("update").description("\u66F4\u65B0\u6253\u6CD5").argument("
|
|
|
615
642
|
}
|
|
616
643
|
const body = {};
|
|
617
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);
|
|
618
650
|
if (opts.body) body.body = opts.body;
|
|
619
651
|
try {
|
|
620
652
|
await client.patch(`/playbooks/${id}`, body);
|
|
@@ -710,15 +742,23 @@ function buildWalkthroughFields(opts) {
|
|
|
710
742
|
if (opts.publicationStatus !== void 0) w.publication_status = opts.publicationStatus;
|
|
711
743
|
return w;
|
|
712
744
|
}
|
|
713
|
-
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\
|
|
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) => {
|
|
714
746
|
const { apiKey, client } = resolveApi(cmd);
|
|
715
747
|
requireApiKey(apiKey);
|
|
716
748
|
const sourceKind = ensureSourceKind(opts.sourceKind);
|
|
717
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
|
+
}
|
|
718
758
|
const w = {
|
|
719
759
|
title: opts.title,
|
|
720
|
-
summary: opts.summary || "",
|
|
721
|
-
body: opts.body || "",
|
|
760
|
+
summary: opts.summaryFile ? readTextFile(opts.summaryFile) : opts.summary || "",
|
|
761
|
+
body: opts.bodyFile ? readTextFile(opts.bodyFile) : opts.body || "",
|
|
722
762
|
source_kind: sourceKind,
|
|
723
763
|
external_url: opts.externalUrl || "",
|
|
724
764
|
poster_preview_at_seconds: Number.isFinite(posterAt) ? posterAt : void 0
|
|
@@ -789,14 +829,22 @@ ${w.body || "(\u65E0)"}`);
|
|
|
789
829
|
console.log(`\u6765\u6E90\uFF1A${w.sourceKind}`);
|
|
790
830
|
if (w.src) console.log(`\u5A92\u4F53\uFF1A${w.src}`);
|
|
791
831
|
});
|
|
792
|
-
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\
|
|
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) => {
|
|
793
833
|
const { apiKey, client } = resolveApi(cmd);
|
|
794
834
|
requireApiKey(apiKey);
|
|
795
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
|
+
}
|
|
796
844
|
const w = buildWalkthroughFields({
|
|
797
845
|
title: opts.title,
|
|
798
|
-
summary: opts.summary,
|
|
799
|
-
body: opts.body,
|
|
846
|
+
summary: opts.summaryFile ? readTextFile(opts.summaryFile) : opts.summary,
|
|
847
|
+
body: opts.bodyFile ? readTextFile(opts.bodyFile) : opts.body,
|
|
800
848
|
sourceKind: opts.sourceKind ? ensureSourceKind(opts.sourceKind) : void 0,
|
|
801
849
|
externalUrl: opts.externalUrl,
|
|
802
850
|
posterAt: Number.isFinite(posterAt) ? posterAt : void 0,
|