@letterstory/cli 0.97.0 → 0.98.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/lib/cli.mjs CHANGED
@@ -58,7 +58,7 @@ import {
58
58
  } from "./commands.mjs";
59
59
 
60
60
  // Keep in sync with cli/package.json.
61
- export const VERSION = "0.97.0";
61
+ export const VERSION = "0.98.0";
62
62
 
63
63
  // Flags that never take a value. Listing them explicitly means `deploy get --json <id>`
64
64
  // can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
@@ -241,6 +241,8 @@ export const ARGS = {
241
241
  },
242
242
  delete_dispatch: {
243
243
  dispatch_id: { positional: 0, label: "dispatch-id", required: true },
244
+ pending: { flag: "pending", enum: ["move", "send"] },
245
+ move_to: { flag: "move-to" },
244
246
  },
245
247
  list_dispatch_links: {},
246
248
  create_dispatch_link: {
@@ -393,14 +395,28 @@ export const ARGS = {
393
395
  },
394
396
  };
395
397
 
398
+ // `message` may be a function of the tool's result, for a line that reports what actually happened.
396
399
  async function run(ctx, tool, message) {
397
400
  refuseUnknownFlags(ctx, ARGS[tool]);
398
401
  const result = await ctx.client.callTool(tool, argsFromFlags(ARGS[tool], ctx.flags, ctx.positionals));
399
- if (message) ok(ctx, message);
402
+ const text = typeof message === "function" ? message(result) : message;
403
+ if (text) ok(ctx, text);
400
404
  printResult(ctx.io, ctx.flags, result);
401
405
  return 0;
402
406
  }
403
407
 
408
+ /** What a desk delete did, in one line: sent and moved counts as the tool reported them. */
409
+ function deleteDispatchLine(result) {
410
+ const sent = Number(result?.sent ?? 0);
411
+ const moved = Number(result?.moved ?? 0);
412
+ const n = (count) => `${count} queued email${count === 1 ? "" : "s"}`;
413
+ if (result?.pending === "send") {
414
+ const base = `Dispatch deleted; ${n(sent)} approved to send.`;
415
+ return moved > 0 ? `${base} ${n(moved)} couldn't be approved and moved to ${result.moved_to}.` : base;
416
+ }
417
+ return `Dispatch deleted; ${n(moved)} moved${moved > 0 ? ` to ${result.moved_to}` : ""}.`;
418
+ }
419
+
404
420
  const SEQUENCES_USAGE = `Usage: sequences <list|get|create|update|pause|resume|enroll|stop|review|links|cakes|heyreach>`;
405
421
  const DISPATCHES_USAGE = `Usage: dispatches <list|create|rename|delete>`;
406
422
 
@@ -422,12 +438,16 @@ export async function cmdDispatches(ctx) {
422
438
  case "delete": {
423
439
  if (!ctx.flags.yes) {
424
440
  const id = flagStr(rest.positionals[0]) ?? "<dispatch-id>";
441
+ const moveTo = flagStr(ctx.flags["move-to"]);
442
+ // The re-run command carries every option given, so copying it does what this line says.
425
443
  ctx.io.error(
426
- `Its queued emails move to the default desk. Re-run with --yes to confirm: ${ctx.bin} dispatches delete ${id} --yes`
444
+ ctx.flags.pending === "send"
445
+ ? `Its queued emails will be SENT now. Re-run with --yes to confirm: ${ctx.bin} dispatches delete ${id} --pending send --yes`
446
+ : `Its queued emails move to ${moveTo ?? "the default desk"}. Re-run with --yes to confirm: ${ctx.bin} dispatches delete ${id}${moveTo ? ` --move-to ${moveTo}` : ""} --yes`
427
447
  );
428
448
  return 1;
429
449
  }
430
- return run(rest, "delete_dispatch", "Dispatch deleted; its queued emails moved to the default desk.");
450
+ return run(rest, "delete_dispatch", deleteDispatchLine);
431
451
  }
432
452
  default:
433
453
  throw new CliError(`Unknown dispatches subcommand: ${sub}. ${DISPATCHES_USAGE}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.97.0",
3
+ "version": "0.98.0",
4
4
  "description": "Spin up and manage Letterstory phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",