@letterstory/cli 0.175.23 → 0.175.25
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/lib/cli.mjs +11 -5
- package/lib/commands/automations.mjs +21 -1
- package/lib/commands/collection.mjs +1 -0
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
import { fetchParkedSections, withoutParked } from "./parked.mjs";
|
|
81
81
|
|
|
82
82
|
// Matches cli/package.json; publish-cli.yml rewrites both to the published version.
|
|
83
|
-
export const VERSION = "0.175.
|
|
83
|
+
export const VERSION = "0.175.25";
|
|
84
84
|
|
|
85
85
|
/** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
|
|
86
86
|
export const EXIT_PAYMENT_REQUIRED = 3;
|
|
@@ -281,8 +281,12 @@ export const BOOLEAN_FLAGS = new Set([
|
|
|
281
281
|
// `automations set --pause | --resume`.
|
|
282
282
|
"pause",
|
|
283
283
|
"resume",
|
|
284
|
+
// `automations set --unpin`: back to a pace, off its weekday.
|
|
285
|
+
"unpin",
|
|
284
286
|
// `collection add "<headline>" --collection <id> --queue`.
|
|
285
287
|
"queue",
|
|
288
|
+
// `collection add ... --queue --own`: a draft you write yourself.
|
|
289
|
+
"own",
|
|
286
290
|
// Bool flags from command ARGS maps that were missing here.
|
|
287
291
|
"apply-rules",
|
|
288
292
|
"async",
|
|
@@ -564,10 +568,12 @@ Reviewers:
|
|
|
564
568
|
automations more --collection <id> New topics it doesn't cover yet
|
|
565
569
|
automations dismiss <topic-id> --collection <id> Set one subject aside
|
|
566
570
|
automations add topic|series|signal|best --collection <id> [--topic <id>] [--goal <target-id>]
|
|
567
|
-
[--seer <id>] [--pace <n>
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
+
[--seer <id>] [--pace <n> | --on "fri 09:00 America/New_York"] [--brief <text>]
|
|
572
|
+
[--new-topic <name>] [--new-series <name>]
|
|
573
|
+
Add one (refused if it says the same as another).
|
|
574
|
+
--on pins it: one post a week, on that day and time
|
|
575
|
+
automations set <automation-id> --collection <id> [--pace <n> | --on "<day> <HH:MM> <tz>" | --unpin]
|
|
576
|
+
[--pause | --resume] [--goal <id>] [--brief <text>] [--remap]
|
|
571
577
|
automations remove <automation-id> --collection <id>
|
|
572
578
|
automate options What an automation can be made of here: the triggers,
|
|
573
579
|
whether each one's events can come yet, and templates
|
|
@@ -5,6 +5,24 @@
|
|
|
5
5
|
import { CliError } from "../client.mjs";
|
|
6
6
|
import { printResult, ok, argsFromFlags, refuseUnknownFlags } from "./shared.mjs";
|
|
7
7
|
|
|
8
|
+
const WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* `--on "fri 09:00 America/New_York"` → { weekday, time, timezone } (the tool's `publish_at`).
|
|
12
|
+
* The weekday is a name (fri, friday) or 0-6; the timezone is an IANA name. Anything else is the
|
|
13
|
+
* tool's to refuse, with its own message, so only the shape is checked here.
|
|
14
|
+
*/
|
|
15
|
+
export function parsePublishAt(text) {
|
|
16
|
+
if (text === undefined || text === true) return undefined;
|
|
17
|
+
const [day, time, timezone, ...extra] = String(text).trim().split(/\s+/);
|
|
18
|
+
if (!day || !time || !timezone || extra.length)
|
|
19
|
+
throw new CliError('--on takes a weekday, a time and a timezone: --on "fri 09:00 America/New_York"');
|
|
20
|
+
const named = WEEKDAYS.indexOf(day.slice(0, 3).toLowerCase());
|
|
21
|
+
const weekday = /^[0-6]$/.test(day) ? Number(day) : named;
|
|
22
|
+
if (weekday < 0) throw new CliError(`--on: "${day}" is not a weekday (mon, tue, … or 0-6, Sunday is 0).`);
|
|
23
|
+
return { weekday, time, timezone };
|
|
24
|
+
}
|
|
25
|
+
|
|
8
26
|
/** See `argsFromFlags` in shared.mjs; `scripts/parity-check.ts` diffs these keys against the tool. */
|
|
9
27
|
export const ARGS = {
|
|
10
28
|
list_automations: {
|
|
@@ -37,6 +55,7 @@ export const ARGS = {
|
|
|
37
55
|
target_id: { flag: "goal" },
|
|
38
56
|
seer_id: { flag: "seer" },
|
|
39
57
|
pace_per_week: { flag: "pace", type: "num" },
|
|
58
|
+
publish_at: { value: (flags) => parsePublishAt(flags.on) },
|
|
40
59
|
brief: { flag: "brief" },
|
|
41
60
|
new_topic: {
|
|
42
61
|
value: (flags) => (typeof flags["new-topic"] === "string" ? { name: flags["new-topic"] } : undefined),
|
|
@@ -49,6 +68,7 @@ export const ARGS = {
|
|
|
49
68
|
collection_id: { flag: "collection", required: true },
|
|
50
69
|
automation_id: { positional: 0, label: "automation-id", required: true },
|
|
51
70
|
pace_per_week: { flag: "pace", type: "num" },
|
|
71
|
+
publish_at: { value: (flags) => (flags.unpin === true ? null : parsePublishAt(flags.on)) },
|
|
52
72
|
paused: {
|
|
53
73
|
value: (flags) => (flags.pause === true ? true : flags.resume === true ? false : undefined),
|
|
54
74
|
},
|
|
@@ -107,7 +127,7 @@ export async function cmdAutomations(ctx) {
|
|
|
107
127
|
case "add":
|
|
108
128
|
return run(rest, "create_automation", "Added.");
|
|
109
129
|
case "set":
|
|
110
|
-
refuseUnknownFlags(rest, ARGS.update_automation, ["pause", "resume", "remap"]);
|
|
130
|
+
refuseUnknownFlags(rest, ARGS.update_automation, ["pause", "resume", "remap", "unpin"]);
|
|
111
131
|
return run(rest, "update_automation", "Changed.");
|
|
112
132
|
case "remove":
|
|
113
133
|
case "rm":
|
|
@@ -96,6 +96,7 @@ export const ARGS = {
|
|
|
96
96
|
headline: { positional: 0, label: "headline", required: true },
|
|
97
97
|
context: { flag: "notes" },
|
|
98
98
|
queue: { flag: "queue", type: "bool" },
|
|
99
|
+
own: { flag: "own", type: "bool" },
|
|
99
100
|
},
|
|
100
101
|
update_suggestion: {
|
|
101
102
|
suggestion_id: { positional: 0, label: "suggestion-id", required: true },
|