sim 2.2.9-preview.209.1 → 2.2.9-preview.211.1

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
@@ -21303,7 +21303,7 @@ var UNKNOWN_OPTION_TOKEN = /^error: unknown option '(.+?)'/;
21303
21303
  function looksLikeAnId(token) {
21304
21304
  return token.length > 2 && !token.startsWith("--") && /^-[A-Za-z0-9_-]*[A-Z0-9][A-Za-z0-9_-]*$/.test(token);
21305
21305
  }
21306
- function addArgumentExamples(command) {
21306
+ function addParseErrorGuidance(command) {
21307
21307
  const outputError = command.configureOutput().outputError;
21308
21308
  if (!outputError)
21309
21309
  throw new Error("Commander output formatter is not configured");
@@ -21317,12 +21317,17 @@ function addArgumentExamples(command) {
21317
21317
  `);
21318
21318
  return;
21319
21319
  }
21320
- if (command.registeredArguments.length === 0)
21321
- return;
21322
21320
  const token = UNKNOWN_OPTION_TOKEN.exec(message)?.[1];
21323
- if (!token || !looksLikeAnId(token))
21321
+ if (!token)
21322
+ return;
21323
+ if (looksLikeAnId(token) && command.registeredArguments.length > 0) {
21324
+ write(`Example: ${commandPath(command)} -- ${token}
21325
+ `);
21324
21326
  return;
21325
- write(`Example: ${commandPath(command)} -- ${token}
21327
+ }
21328
+ const flags = command.options.filter((option) => !option.hidden).map((option) => option.flags);
21329
+ write(flags.length > 0 ? `Options for ${commandPath(command)}: ${flags.join(", ")}
21330
+ ` : `${commandPath(command)} takes no options.
21326
21331
  `);
21327
21332
  }
21328
21333
  });
@@ -21449,7 +21454,7 @@ function configureOperation(command, operation, spec) {
21449
21454
  return command;
21450
21455
  }
21451
21456
  function buildLeaf(operation, spec, leafName) {
21452
- return addArgumentExamples(configureOperation(new Command(leafName), operation, spec));
21457
+ return addParseErrorGuidance(configureOperation(new Command(leafName), operation, spec));
21453
21458
  }
21454
21459
  function addRenamedCommand(groups, operation, spec, from, to) {
21455
21460
  const segments = from.split(" ");
package/dist/runtime.js CHANGED
@@ -21352,7 +21352,7 @@ var UNKNOWN_OPTION_TOKEN = /^error: unknown option '(.+?)'/;
21352
21352
  function looksLikeAnId(token) {
21353
21353
  return token.length > 2 && !token.startsWith("--") && /^-[A-Za-z0-9_-]*[A-Z0-9][A-Za-z0-9_-]*$/.test(token);
21354
21354
  }
21355
- function addArgumentExamples(command) {
21355
+ function addParseErrorGuidance(command) {
21356
21356
  const outputError = command.configureOutput().outputError;
21357
21357
  if (!outputError)
21358
21358
  throw new Error("Commander output formatter is not configured");
@@ -21366,12 +21366,17 @@ function addArgumentExamples(command) {
21366
21366
  `);
21367
21367
  return;
21368
21368
  }
21369
- if (command.registeredArguments.length === 0)
21370
- return;
21371
21369
  const token = UNKNOWN_OPTION_TOKEN.exec(message)?.[1];
21372
- if (!token || !looksLikeAnId(token))
21370
+ if (!token)
21371
+ return;
21372
+ if (looksLikeAnId(token) && command.registeredArguments.length > 0) {
21373
+ write(`Example: ${commandPath(command)} -- ${token}
21374
+ `);
21373
21375
  return;
21374
- write(`Example: ${commandPath(command)} -- ${token}
21376
+ }
21377
+ const flags = command.options.filter((option) => !option.hidden).map((option) => option.flags);
21378
+ write(flags.length > 0 ? `Options for ${commandPath(command)}: ${flags.join(", ")}
21379
+ ` : `${commandPath(command)} takes no options.
21375
21380
  `);
21376
21381
  }
21377
21382
  });
@@ -21498,7 +21503,7 @@ function configureOperation(command, operation, spec) {
21498
21503
  return command;
21499
21504
  }
21500
21505
  function buildLeaf(operation, spec, leafName) {
21501
- return addArgumentExamples(configureOperation(new Command(leafName), operation, spec));
21506
+ return addParseErrorGuidance(configureOperation(new Command(leafName), operation, spec));
21502
21507
  }
21503
21508
  function addRenamedCommand(groups, operation, spec, from, to) {
21504
21509
  const segments = from.split(" ");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim",
3
- "version": "2.2.9-preview.209.1",
3
+ "version": "2.2.9-preview.211.1",
4
4
  "description": "Sim CLI - talk to the Sim API from your terminal",
5
5
  "type": "module",
6
6
  "imports": {