@nuelink/nuelink-cli 1.4.1 → 1.4.3

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/src/commands.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { readFile, stat } from "node:fs/promises";
2
2
  import readline from "node:readline";
3
3
  import path from "node:path";
4
- import chalk from "chalk";
5
-
6
- import { clearApiKey, maskToken, readConfig, resolveApiKey, CONFIG_FILE, decryptApiKey, saveApiKey } from "./config.js";
7
- import { CliError, printCliError } from "./errors.js";
4
+ import chalk from "chalk";
5
+
6
+ import { clearApiKey, maskToken, readConfig, resolveApiKey, CONFIG_FILE, decryptApiKey, saveApiKey } from "./config.js";
7
+ import { CliError, printCliError } from "./errors.js";
8
8
  import { brandPath, collectionPath, nuelinkRequest } from "./http.js";
9
9
  import { buildPostPayload, parseCsv, validateRawPostPayload, VALID_PUBLISH_MODES } from "./postPayload.js";
10
10
  import {
@@ -12,6 +12,11 @@ import {
12
12
  VALID_AUTOMATION_TYPES,
13
13
  VALID_IMPORT_AS_TYPES,
14
14
  VALID_MEDIA_FILTER_TYPES,
15
+ VALID_POST_STATUSES,
16
+ VALID_POST_TYPES,
17
+ VALID_POSTING_TYPES,
18
+ VALID_POST_SORT_FIELDS,
19
+ VALID_SORT_ORDERS,
15
20
  normalizeEnum,
16
21
  parseBooleanStrict,
17
22
  parseIntegerInRange,
@@ -20,10 +25,11 @@ import {
20
25
  parsePositiveInteger,
21
26
  splitCsv,
22
27
  validateHttpUrl,
23
- validateMediaFile,
24
- validateQueueSlots,
25
- validateRequiredString,
26
- } from "./validation.js";
28
+ validateMediaFile,
29
+ validatePostDateTime,
30
+ validateQueueSlots,
31
+ validateRequiredString,
32
+ } from "./validation.js";
27
33
 
28
34
  function extractApiKeyArg(args) {
29
35
  const sanitizedArgs = [];
@@ -180,19 +186,19 @@ async function executeRequest(program, runtimeApiKey, request) {
180
186
  });
181
187
  }
182
188
 
183
- function withCommandErrorHandling(program, handler) {
184
- return async (...args) => {
185
- try {
186
- await handler(...args);
187
- } catch (error) {
188
- printCliError(error, {
189
- json: Boolean(program.opts().json),
190
- fallbackCode: "VALIDATION_ERROR",
191
- });
192
- process.exitCode = 1;
193
- }
194
- };
195
- }
189
+ function withCommandErrorHandling(program, handler) {
190
+ return async (...args) => {
191
+ try {
192
+ await handler(...args);
193
+ } catch (error) {
194
+ printCliError(error, {
195
+ json: Boolean(program.opts().json),
196
+ fallbackCode: "VALIDATION_ERROR",
197
+ });
198
+ process.exitCode = 1;
199
+ }
200
+ };
201
+ }
196
202
 
197
203
  function registerCommands(program, runtimeApiKey, cliVersion) {
198
204
  program
@@ -202,7 +208,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
202
208
  .option("-a, --api-key <apiKey>", "Use API key for this invocation only")
203
209
  .option("--auth <apiKey>", "Deprecated alias for --api-key")
204
210
  .option("--dry-run", "Print the validated request without sending it")
205
- .option("--json", "Output machine-readable JSON for successes and failures")
211
+ .option("--json", "Output machine-readable JSON for successes and failures")
206
212
  .option("--quiet", "Suppress non-essential success banners");
207
213
 
208
214
  program
@@ -210,7 +216,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
210
216
  .description("Persist an API key to local config")
211
217
  .option("--api-key <apiKey>", "API key to save (prefer stdin or interactive prompt)")
212
218
  .option("--stdin", "Read API key from stdin")
213
- .action(withCommandErrorHandling(program, async (options) => {
219
+ .action(withCommandErrorHandling(program, async (options) => {
214
220
  const apiKey = await resolveLoginApiKey(options, runtimeApiKey);
215
221
 
216
222
  if (!apiKey) {
@@ -219,95 +225,102 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
219
225
 
220
226
  process.env.NUELINK_API_KEY = apiKey;
221
227
  await saveApiKey(apiKey);
222
- if (program.opts().json) {
223
- console.log(JSON.stringify({ success: true, source: "saved_config" }));
224
- } else {
225
- console.log(chalk.green("API key saved to local config."));
226
- }
227
- }));
228
+ if (program.opts().json) {
229
+ console.log(JSON.stringify({ success: true, source: "saved_config" }));
230
+ } else {
231
+ console.log(chalk.green("API key saved to local config."));
232
+ }
233
+ }));
228
234
 
229
235
  program
230
236
  .command("auth:clear")
231
237
  .description("Remove the saved API key")
232
- .action(withCommandErrorHandling(program, async () => {
233
- await clearApiKey();
234
- if (program.opts().json) {
235
- console.log(JSON.stringify({ success: true, cleared: true }));
236
- } else {
237
- console.log(chalk.yellow("Saved API key removed."));
238
- }
239
- }));
238
+ .action(withCommandErrorHandling(program, async () => {
239
+ await clearApiKey();
240
+ if (program.opts().json) {
241
+ console.log(JSON.stringify({ success: true, cleared: true }));
242
+ } else {
243
+ console.log(chalk.yellow("Saved API key removed."));
244
+ }
245
+ }));
240
246
 
241
247
  program
242
248
  .command("auth:status")
243
249
  .description("Show where auth is currently resolved from")
244
- .action(withCommandErrorHandling(program, async () => {
245
- if (runtimeApiKey) {
246
- if (program.opts().json) {
247
- console.log(JSON.stringify({ authenticated: true, source: "runtime_flag", token: maskToken(runtimeApiKey) }));
248
- } else {
249
- console.log(chalk.green(`Auth source: runtime CLI flag (${maskToken(runtimeApiKey)})`));
250
- }
251
- return;
252
- }
253
-
254
- if (process.env.NUELINK_API_KEY) {
255
- if (program.opts().json) {
256
- console.log(JSON.stringify({ authenticated: true, source: "environment", token: maskToken(process.env.NUELINK_API_KEY) }));
257
- } else {
258
- console.log(chalk.green(`Auth source: NUELINK_API_KEY (${maskToken(process.env.NUELINK_API_KEY)})`));
259
- }
260
- return;
261
- }
250
+ .action(withCommandErrorHandling(program, async () => {
251
+ if (runtimeApiKey) {
252
+ if (program.opts().json) {
253
+ console.log(JSON.stringify({ authenticated: true, source: "runtime_flag", token: maskToken(runtimeApiKey) }));
254
+ } else {
255
+ console.log(chalk.green(`Auth source: runtime CLI flag (${maskToken(runtimeApiKey)})`));
256
+ }
257
+ return;
258
+ }
259
+
260
+ if (process.env.NUELINK_API_KEY) {
261
+ if (program.opts().json) {
262
+ console.log(JSON.stringify({ authenticated: true, source: "environment", token: maskToken(process.env.NUELINK_API_KEY) }));
263
+ } else {
264
+ console.log(chalk.green(`Auth source: NUELINK_API_KEY (${maskToken(process.env.NUELINK_API_KEY)})`));
265
+ }
266
+ return;
267
+ }
262
268
 
263
269
  const config = await readConfig();
264
- const storedApiKey = decryptApiKey(config);
265
- if (storedApiKey) {
266
- let lastUpdated;
267
-
268
- try {
269
- const fileStat = await stat(CONFIG_FILE);
270
- lastUpdated = fileStat.mtime.toISOString();
271
- } catch {
272
- // Ignore non-critical stat failure.
273
- }
274
-
275
- if (program.opts().json) {
276
- console.log(JSON.stringify({
277
- authenticated: true,
278
- source: "saved_config",
279
- token: maskToken(storedApiKey),
280
- configPath: CONFIG_FILE,
281
- lastUpdated: lastUpdated || null,
282
- }));
283
- } else {
284
- console.log(chalk.green(`Auth source: saved config (${maskToken(storedApiKey)})`));
285
- console.log(chalk.blue(`Config path: ${CONFIG_FILE}`));
286
- if (lastUpdated) console.log(chalk.blue(`Last updated: ${lastUpdated}`));
287
- }
288
-
289
- return;
290
- }
291
-
292
- throw new CliError(
293
- "AUTH_MISSING",
294
- "No API key configured. Use auth:login to save one, or pass --api-key for a single command.",
295
- );
296
- }));
297
-
298
- program
299
- .command("me")
300
- .description("Get current profile")
301
- .action(withCommandErrorHandling(program, async () => {
270
+ const storedApiKey = decryptApiKey(config);
271
+ if (storedApiKey) {
272
+ let lastUpdated;
273
+
274
+ try {
275
+ const fileStat = await stat(CONFIG_FILE);
276
+ lastUpdated = fileStat.mtime.toISOString();
277
+ } catch {
278
+ // Ignore non-critical stat failure.
279
+ }
280
+
281
+ if (program.opts().json) {
282
+ console.log(JSON.stringify({
283
+ authenticated: true,
284
+ source: "saved_config",
285
+ token: maskToken(storedApiKey),
286
+ configPath: CONFIG_FILE,
287
+ lastUpdated: lastUpdated || null,
288
+ }));
289
+ } else {
290
+ console.log(chalk.green(`Auth source: saved config (${maskToken(storedApiKey)})`));
291
+ console.log(chalk.blue(`Config path: ${CONFIG_FILE}`));
292
+ if (lastUpdated) console.log(chalk.blue(`Last updated: ${lastUpdated}`));
293
+ }
294
+
295
+ return;
296
+ }
297
+
298
+ throw new CliError(
299
+ "AUTH_MISSING",
300
+ "No API key configured. Use auth:login to save one, or pass --api-key for a single command.",
301
+ );
302
+ }));
303
+
304
+ program
305
+ .command("auth:validate")
306
+ .description("Validate the configured API key with the Public API")
307
+ .action(withCommandErrorHandling(program, async () => {
308
+ await executeRequest(program, runtimeApiKey, { endpoint: "/auth" });
309
+ }));
310
+
311
+ program
312
+ .command("me")
313
+ .description("Get current profile")
314
+ .action(withCommandErrorHandling(program, async () => {
302
315
  await executeRequest(program, runtimeApiKey, { endpoint: "/me" });
303
316
  }));
304
317
 
305
- program
306
- .command("brands")
318
+ program
319
+ .command("brands")
307
320
  .description("List brands")
308
321
  .option("--per-page <number>", "Items per page", "25")
309
322
  .option("--page <number>", "Page number", "1")
310
- .action(withCommandErrorHandling(program, async (options) => {
323
+ .action(withCommandErrorHandling(program, async (options) => {
311
324
  await executeRequest(program, runtimeApiKey, {
312
325
  endpoint: "/brands",
313
326
  query: {
@@ -317,13 +330,13 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
317
330
  });
318
331
  }));
319
332
 
320
- program
321
- .command("collections")
333
+ program
334
+ .command("collections")
322
335
  .description("List collections for a brand")
323
336
  .requiredOption("--brand-id <id>", "Brand ID")
324
337
  .option("--per-page <number>", "Items per page", "25")
325
338
  .option("--page <number>", "Page number", "1")
326
- .action(withCommandErrorHandling(program, async (options) => {
339
+ .action(withCommandErrorHandling(program, async (options) => {
327
340
  await executeRequest(program, runtimeApiKey, {
328
341
  endpoint: `${brandPath(parsePositiveInteger(options.brandId, "brand-id"))}/collections`,
329
342
  query: {
@@ -333,8 +346,8 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
333
346
  });
334
347
  }));
335
348
 
336
- program
337
- .command("collections:create")
349
+ program
350
+ .command("collections:create")
338
351
  .description("Create a collection")
339
352
  .requiredOption("--brand-id <id>", "Brand ID")
340
353
  .requiredOption("--title <title>", "Collection title")
@@ -342,7 +355,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
342
355
  .option("--max-republish <number>", "Max republish")
343
356
  .option("--channels <ids>", "Comma-separated channel IDs")
344
357
  .option("--queues <slots>", "Comma-separated queue slots (e.g. Mon 10:10,Mon 12:12)")
345
- .action(withCommandErrorHandling(program, async (options) => {
358
+ .action(withCommandErrorHandling(program, async (options) => {
346
359
  const channels = splitCsv(options.channels).map((id) => parsePositiveInteger(id, "channel-id"));
347
360
  const queues = validateQueueSlots(splitCsv(options.queues));
348
361
 
@@ -350,7 +363,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
350
363
  method: "POST",
351
364
  endpoint: `${brandPath(parsePositiveInteger(options.brandId, "brand-id"))}/collections`,
352
365
  body: {
353
- title: validateRequiredString(options.title, 255, "title"),
366
+ title: validateRequiredString(options.title, 255, "title"),
354
367
  description: validateMaxLength(options.description, 1000, "description"),
355
368
  maxRepublish: parseOptionalNonNegativeInteger(options.maxRepublish, "max-republish"),
356
369
  channels,
@@ -359,13 +372,13 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
359
372
  });
360
373
  }));
361
374
 
362
- program
363
- .command("automations")
375
+ program
376
+ .command("automations")
364
377
  .description("List automations for a brand")
365
378
  .requiredOption("--brand-id <id>", "Brand ID")
366
379
  .option("--per-page <number>", "Items per page", "25")
367
380
  .option("--page <number>", "Page number", "1")
368
- .action(withCommandErrorHandling(program, async (options) => {
381
+ .action(withCommandErrorHandling(program, async (options) => {
369
382
  await executeRequest(program, runtimeApiKey, {
370
383
  endpoint: `${brandPath(parsePositiveInteger(options.brandId, "brand-id"))}/automations`,
371
384
  query: {
@@ -375,8 +388,8 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
375
388
  });
376
389
  }));
377
390
 
378
- program
379
- .command("automations:create")
391
+ program
392
+ .command("automations:create")
380
393
  .description("Create an automation")
381
394
  .requiredOption("--brand-id <id>", "Brand ID")
382
395
  .requiredOption("--collection-id <id>", "Collection ID")
@@ -386,12 +399,12 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
386
399
  .requiredOption("--title <title>", "Automation title")
387
400
  .option("--type <type>", "Automation type", "FEED")
388
401
  .option("--dynamic-title <text>", "Dynamic title", "{{title}}")
389
- .option("--dynamic-body <text>", "Dynamic body", "{title} {link}")
402
+ .option("--dynamic-body <text>", "Dynamic body")
390
403
  .option("--description <text>", "Automation description")
391
404
  .option("--load-old-posts <boolean>", "Import existing feed items: true/false")
392
405
  .option("--add-posts-as-draft <boolean>", "Create imported posts as drafts: true/false")
393
406
  .option("--refresh-rate <hours>", "Refresh interval (24, 12, 6, or 1 hours)")
394
- .action(withCommandErrorHandling(program, async (options) => {
407
+ .action(withCommandErrorHandling(program, async (options) => {
395
408
  await executeRequest(program, runtimeApiKey, {
396
409
  method: "POST",
397
410
  endpoint: `${brandPath(parsePositiveInteger(options.brandId, "brand-id"))}/automations`,
@@ -400,7 +413,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
400
413
  feedUrl: validateHttpUrl(options.feedUrl, "feed-url"),
401
414
  importAsType: normalizeEnum(options.importAsType, "import-as-type", VALID_IMPORT_AS_TYPES),
402
415
  subType: normalizeEnum(options.subType, "sub-type", VALID_AUTOMATION_SUB_TYPES),
403
- title: validateRequiredString(options.title, 255, "title"),
416
+ title: validateRequiredString(options.title, 255, "title"),
404
417
  type: normalizeEnum(options.type, "type", VALID_AUTOMATION_TYPES),
405
418
  dynamicTitle: validateMaxLength(options.dynamicTitle, 255, "dynamic-title"),
406
419
  dynamicBody: validateMaxLength(options.dynamicBody, 255, "dynamic-body"),
@@ -414,13 +427,13 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
414
427
  });
415
428
  }));
416
429
 
417
- program
418
- .command("channels")
430
+ program
431
+ .command("channels")
419
432
  .description("List channels for a brand")
420
433
  .requiredOption("--brand-id <id>", "Brand ID")
421
434
  .option("--per-page <number>", "Items per page", "25")
422
435
  .option("--page <number>", "Page number", "1")
423
- .action(withCommandErrorHandling(program, async (options) => {
436
+ .action(withCommandErrorHandling(program, async (options) => {
424
437
  await executeRequest(program, runtimeApiKey, {
425
438
  endpoint: `${brandPath(parsePositiveInteger(options.brandId, "brand-id"))}/channels`,
426
439
  query: {
@@ -430,14 +443,14 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
430
443
  });
431
444
  }));
432
445
 
433
- program
434
- .command("media")
446
+ program
447
+ .command("media")
435
448
  .description("List media for a brand")
436
449
  .requiredOption("--brand-id <id>", "Brand ID")
437
450
  .option("--type <type>", `Media type filter (${VALID_MEDIA_FILTER_TYPES.join(", ")})`)
438
451
  .option("--per-page <number>", "Items per page", "25")
439
452
  .option("--page <number>", "Page number", "1")
440
- .action(withCommandErrorHandling(program, async (options) => {
453
+ .action(withCommandErrorHandling(program, async (options) => {
441
454
  await executeRequest(program, runtimeApiKey, {
442
455
  endpoint: `${brandPath(parsePositiveInteger(options.brandId, "brand-id"))}/media`,
443
456
  query: {
@@ -450,29 +463,29 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
450
463
  });
451
464
  }));
452
465
 
453
- program
454
- .command("media:upload")
466
+ program
467
+ .command("media:upload")
455
468
  .description("Upload a media file")
456
469
  .requiredOption("--brand-id <id>", "Brand ID")
457
470
  .requiredOption("--file <path>", "Path to local file")
458
- .action(withCommandErrorHandling(program, async (options) => {
459
- const brandId = parsePositiveInteger(options.brandId, "brand-id");
460
- const fileStat = await stat(options.file);
461
- const { mediaType, size } = validateMediaFile(options.file, fileStat);
462
- let multipart = true;
463
-
464
- if (!program.opts().dryRun) {
465
- const formData = new FormData();
466
- const fileBuffer = await readFile(options.file);
467
- const fileBlob = new Blob([fileBuffer], { type: mediaType });
468
- formData.append("media", fileBlob, path.basename(options.file));
469
- multipart = formData;
470
- }
471
+ .action(withCommandErrorHandling(program, async (options) => {
472
+ const brandId = parsePositiveInteger(options.brandId, "brand-id");
473
+ const fileStat = await stat(options.file);
474
+ const { mediaType, size } = validateMediaFile(options.file, fileStat);
475
+ let multipart = true;
476
+
477
+ if (!program.opts().dryRun) {
478
+ const formData = new FormData();
479
+ const fileBuffer = await readFile(options.file);
480
+ const fileBlob = new Blob([fileBuffer], { type: mediaType });
481
+ formData.append("media", fileBlob, path.basename(options.file));
482
+ multipart = formData;
483
+ }
471
484
 
472
485
  await executeRequest(program, runtimeApiKey, {
473
486
  method: "POST",
474
487
  endpoint: `${brandPath(brandId)}/media`,
475
- multipart,
488
+ multipart,
476
489
  dryRunBody: {
477
490
  file: path.basename(options.file),
478
491
  size,
@@ -481,14 +494,39 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
481
494
  });
482
495
  }));
483
496
 
484
- program
485
- .command("posts")
497
+ program
498
+ .command("posts")
486
499
  .description("List posts in a collection")
487
500
  .requiredOption("--brand-id <id>", "Brand ID")
488
501
  .requiredOption("--collection-id <id>", "Collection ID")
489
502
  .option("--per-page <number>", "Items per page", "25")
490
503
  .option("--page <number>", "Page number", "1")
491
- .action(withCommandErrorHandling(program, async (options) => {
504
+ .option("--status <status>", `Post status (${VALID_POST_STATUSES.join(", ")})`)
505
+ .option("--post-type <type>", `Post type (${VALID_POST_TYPES.join(", ")})`)
506
+ .option("--posting-type <type>", `Posting type (${VALID_POSTING_TYPES.join(", ")})`)
507
+ .option("--created-from <datetime>", "Created at or after UTC time (YYYY-MM-DD HH:mm:ss)")
508
+ .option("--created-to <datetime>", "Created at or before UTC time (YYYY-MM-DD HH:mm:ss)")
509
+ .option("--sort-by <field>", `Sort field (${VALID_POST_SORT_FIELDS.join(", ")})`)
510
+ .option("--sort-order <order>", `Sort order (${VALID_SORT_ORDERS.join(", ")})`)
511
+ .action(withCommandErrorHandling(program, async (options) => {
512
+ const createdFrom = validatePostDateTime(options.createdFrom, "created-from");
513
+ const createdTo = validatePostDateTime(options.createdTo, "created-to");
514
+ if (createdFrom && createdTo && createdTo < createdFrom) {
515
+ throw new Error("created-to must not precede created-from.");
516
+ }
517
+ const sortBy = options.sortBy === undefined
518
+ ? undefined
519
+ : String(options.sortBy).trim().toLowerCase();
520
+ if (sortBy && !VALID_POST_SORT_FIELDS.includes(sortBy)) {
521
+ throw new Error(`Invalid sort-by "${options.sortBy}". Expected one of: ${VALID_POST_SORT_FIELDS.join(", ")}.`);
522
+ }
523
+ const sortOrder = options.sortOrder === undefined
524
+ ? undefined
525
+ : String(options.sortOrder).trim().toLowerCase();
526
+ if (sortOrder && !VALID_SORT_ORDERS.includes(sortOrder)) {
527
+ throw new Error(`Invalid sort-order "${options.sortOrder}". Expected one of: ${VALID_SORT_ORDERS.join(", ")}.`);
528
+ }
529
+
492
530
  await executeRequest(program, runtimeApiKey, {
493
531
  endpoint: `${collectionPath(
494
532
  parsePositiveInteger(options.brandId, "brand-id"),
@@ -497,17 +535,30 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
497
535
  query: {
498
536
  per_page: parseIntegerInRange(options.perPage, "per-page", 1, 100),
499
537
  page: parsePositiveInteger(options.page, "page"),
538
+ status: options.status
539
+ ? normalizeEnum(options.status, "status", VALID_POST_STATUSES)
540
+ : undefined,
541
+ post_type: options.postType
542
+ ? normalizeEnum(options.postType, "post-type", VALID_POST_TYPES)
543
+ : undefined,
544
+ posting_type: options.postingType
545
+ ? normalizeEnum(options.postingType, "posting-type", VALID_POSTING_TYPES)
546
+ : undefined,
547
+ created_from: createdFrom,
548
+ created_to: createdTo,
549
+ sort_by: sortBy,
550
+ sort_order: sortOrder,
500
551
  },
501
552
  });
502
553
  }));
503
554
 
504
- program
505
- .command("posts:add-json")
555
+ program
556
+ .command("posts:add-json")
506
557
  .description("Create a post using a JSON payload file")
507
558
  .requiredOption("--brand-id <id>", "Brand ID")
508
559
  .requiredOption("--collection-id <id>", "Collection ID")
509
560
  .requiredOption("--payload <file>", "Path to JSON payload file")
510
- .action(withCommandErrorHandling(program, async (options) => {
561
+ .action(withCommandErrorHandling(program, async (options) => {
511
562
  const payloadText = options.payload === "-"
512
563
  ? await readStdinText()
513
564
  : await readFile(options.payload, "utf8");
@@ -523,8 +574,8 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
523
574
  });
524
575
  }));
525
576
 
526
- program
527
- .command("posts:create")
577
+ program
578
+ .command("posts:create")
528
579
  .description("Create a post using CLI options")
529
580
  .requiredOption("--brand-id <id>", "Brand ID")
530
581
  .requiredOption("--collection-id <id>", "Collection ID")
@@ -532,6 +583,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
532
583
  .option("--caption <text>", "Post caption/body")
533
584
  .option("--alt <text>", "Alt text")
534
585
  .option("--link <url>", "Post link")
586
+ .option("--auto-thread-text <boolean>", "Automatically thread text: true/false")
535
587
  .option("--publish-mode <mode>", `Publish mode (${VALID_PUBLISH_MODES.join(", ")})`, "DRAFT")
536
588
  .option("--scheduled-at <value>", "Publish datetime (YYYY-MM-DD HH:mm:ss) or null")
537
589
  .option("--post-as-story <boolean>", "Post as story: true/false")
@@ -556,7 +608,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
556
608
  .option("--youtube-tags <tags>", "Comma-separated YouTube tags")
557
609
  .option("--youtube-playlists <json>", "YouTube playlists JSON string")
558
610
  .option("--googlemybusiness-upload-to-photos-section <boolean>", "Upload to Google Business Profile photos: true/false")
559
- .action(withCommandErrorHandling(program, async (options) => {
611
+ .action(withCommandErrorHandling(program, async (options) => {
560
612
  const payload = buildPostPayload(options);
561
613
 
562
614
  await executeRequest(program, runtimeApiKey, {