poe-code 3.0.373 → 3.0.374

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/dist/index.js CHANGED
@@ -90989,6 +90989,37 @@ function resolveOutput(resolvedFlags) {
90989
90989
  }
90990
90990
  return "rich";
90991
90991
  }
90992
+ function resolveOutputFromArgv(argv) {
90993
+ for (let index = 0; index < argv.length; index += 1) {
90994
+ const token = argv[index] ?? "";
90995
+ if (token === "--json") {
90996
+ return "json";
90997
+ }
90998
+ if (token === "--md" || token === "--markdown") {
90999
+ return "md";
91000
+ }
91001
+ if (token === "--output") {
91002
+ const value = argv[index + 1];
91003
+ if (value === "rich" || value === "md" || value === "json") {
91004
+ return value;
91005
+ }
91006
+ if (value === "markdown") {
91007
+ return "md";
91008
+ }
91009
+ continue;
91010
+ }
91011
+ if (token.startsWith("--output=")) {
91012
+ const value = token.slice("--output=".length);
91013
+ if (value === "rich" || value === "md" || value === "json") {
91014
+ return value;
91015
+ }
91016
+ if (value === "markdown") {
91017
+ return "md";
91018
+ }
91019
+ }
91020
+ }
91021
+ return "rich";
91022
+ }
90992
91023
  function toDesignSystemOutput(output) {
90993
91024
  return DESIGN_SYSTEM_OUTPUT_BY_MODE[output];
90994
91025
  }
@@ -92463,76 +92494,78 @@ function renderHttpError(error3, options) {
92463
92494
  `);
92464
92495
  }
92465
92496
  }
92466
- function handleRunError(error3, options) {
92497
+ async function handleRunError(error3, options) {
92467
92498
  const logger2 = createLogger();
92468
- if (error3 instanceof UserError) {
92469
- renderCliErrorPattern(
92470
- options.userErrorPattern === "usage" ? {
92471
- kind: "usage",
92472
- message: error3.message,
92473
- rootUsageName: options.rootUsageName,
92474
- commandPath: options.commandPath
92475
- } : {
92476
- kind: "runtime-user",
92477
- message: error3.message
92478
- }
92479
- );
92480
- return;
92481
- }
92482
- if (error3 instanceof Error && error3.name === "ToolcraftBugError") {
92483
- renderCliErrorPattern({
92484
- kind: "toolcraft-bug",
92485
- error: error3,
92486
- debugStackMode: options.debugStackMode
92487
- });
92488
- return;
92489
- }
92490
- if (error3 instanceof CommanderError2) {
92491
- process.exitCode = error3.exitCode;
92492
- if (error3.code === "commander.helpDisplayed" || error3.code === "commander.version") {
92499
+ await withOutputFormat2(options.output, async () => {
92500
+ if (error3 instanceof UserError) {
92501
+ renderCliErrorPattern(
92502
+ options.userErrorPattern === "usage" ? {
92503
+ kind: "usage",
92504
+ message: error3.message,
92505
+ rootUsageName: options.rootUsageName,
92506
+ commandPath: options.commandPath
92507
+ } : {
92508
+ kind: "runtime-user",
92509
+ message: error3.message
92510
+ }
92511
+ );
92493
92512
  return;
92494
92513
  }
92495
- if (error3.code === "commander.unknownCommand") {
92496
- logger2.error(
92497
- appendUsagePointer(
92498
- formatUnknownCommandError(error3, options.program, options.argv ?? process.argv),
92499
- {
92500
- rootUsageName: options.rootUsageName,
92501
- commandPath: options.commandPath
92502
- }
92503
- )
92504
- );
92514
+ if (error3 instanceof Error && error3.name === "ToolcraftBugError") {
92515
+ renderCliErrorPattern({
92516
+ kind: "toolcraft-bug",
92517
+ error: error3,
92518
+ debugStackMode: options.debugStackMode
92519
+ });
92505
92520
  return;
92506
92521
  }
92507
- if (error3.code === "commander.unknownOption") {
92508
- const argv = options.argv ?? process.argv;
92522
+ if (error3 instanceof CommanderError2) {
92523
+ process.exitCode = error3.exitCode;
92524
+ if (error3.code === "commander.helpDisplayed" || error3.code === "commander.version") {
92525
+ return;
92526
+ }
92527
+ if (error3.code === "commander.unknownCommand") {
92528
+ logger2.error(
92529
+ appendUsagePointer(
92530
+ formatUnknownCommandError(error3, options.program, options.argv ?? process.argv),
92531
+ {
92532
+ rootUsageName: options.rootUsageName,
92533
+ commandPath: options.commandPath
92534
+ }
92535
+ )
92536
+ );
92537
+ return;
92538
+ }
92539
+ if (error3.code === "commander.unknownOption") {
92540
+ const argv = options.argv ?? process.argv;
92541
+ logger2.error(
92542
+ appendUsagePointer(formatUnknownOptionError(error3, options.program, argv), {
92543
+ rootUsageName: options.rootUsageName,
92544
+ commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, argv)
92545
+ })
92546
+ );
92547
+ return;
92548
+ }
92509
92549
  logger2.error(
92510
- appendUsagePointer(formatUnknownOptionError(error3, options.program, argv), {
92550
+ appendUsagePointer(formatCommanderErrorMessage(error3), {
92511
92551
  rootUsageName: options.rootUsageName,
92512
- commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, argv)
92552
+ commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, options.argv ?? process.argv)
92513
92553
  })
92514
92554
  );
92515
92555
  return;
92516
92556
  }
92517
- logger2.error(
92518
- appendUsagePointer(formatCommanderErrorMessage(error3), {
92519
- rootUsageName: options.rootUsageName,
92520
- commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, options.argv ?? process.argv)
92521
- })
92522
- );
92523
- return;
92524
- }
92525
- if (isHttpErrorLike(error3)) {
92526
- renderHttpError(error3, options);
92527
- process.exitCode = 1;
92528
- return;
92529
- }
92530
- const message2 = error3 instanceof Error ? error3.message : String(error3);
92531
- renderCliErrorPattern({
92532
- kind: "unexpected",
92533
- message: message2,
92534
- stack: error3 instanceof Error ? error3.stack : void 0,
92535
- debugStackMode: options.debugStackMode
92557
+ if (isHttpErrorLike(error3)) {
92558
+ renderHttpError(error3, options);
92559
+ process.exitCode = 1;
92560
+ return;
92561
+ }
92562
+ const message2 = error3 instanceof Error ? error3.message : String(error3);
92563
+ renderCliErrorPattern({
92564
+ kind: "unexpected",
92565
+ message: message2,
92566
+ stack: error3 instanceof Error ? error3.stack : void 0,
92567
+ debugStackMode: options.debugStackMode
92568
+ });
92536
92569
  });
92537
92570
  }
92538
92571
  function formatCommanderErrorMessage(error3) {
@@ -92857,8 +92890,9 @@ async function runCLI(roots, options = {}) {
92857
92890
  process.stderr.write(`Saved error report to ${report.displayPath}
92858
92891
  `);
92859
92892
  }
92860
- handleRunError(error3, {
92893
+ await handleRunError(error3, {
92861
92894
  debugStackMode: resolvedFlags !== void 0 ? resolveDebugStackMode(resolvedFlags.debug) : getDebugStackModeFromArgv(process.argv),
92895
+ output: resolvedFlags !== void 0 ? resolveOutput(resolvedFlags) : resolveOutputFromArgv(process.argv),
92862
92896
  verbose: resolvedFlags ? Boolean(resolvedFlags.verbose) : process.argv.includes("--verbose"),
92863
92897
  program,
92864
92898
  argv: process.argv,
@@ -139327,7 +139361,7 @@ var init_package2 = __esm({
139327
139361
  "package.json"() {
139328
139362
  package_default2 = {
139329
139363
  name: "poe-code",
139330
- version: "3.0.373",
139364
+ version: "3.0.374",
139331
139365
  description: "CLI tool to configure Poe API for developer workflows.",
139332
139366
  type: "module",
139333
139367
  main: "./dist/index.js",