@soat/cli 0.14.5 → 0.14.7

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.
Files changed (2) hide show
  1. package/dist/index.mjs +39 -2
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -11,7 +11,7 @@ import { load } from "js-yaml";
11
11
  import * as os from "node:os";
12
12
 
13
13
  //#region package.json
14
- var version = "0.14.5";
14
+ var version = "0.14.7";
15
15
 
16
16
  //#endregion
17
17
  //#region src/cli-wrappers/wrappers/formations.ts
@@ -228,6 +228,30 @@ var parseUnknownWithRepeats = args => {
228
228
  repeated
229
229
  };
230
230
  };
231
+ /**
232
+ * Extracts bare (non-`--flag`) tokens from raw CLI args, e.g. the `frm_123` in
233
+ * `soat get-formation frm_123`. Walks the same flag/value pairing as
234
+ * `parseUnknownWithRepeats` so a flag's value (`--name frm_123`) is never
235
+ * mistaken for a standalone positional argument.
236
+ */
237
+ var extractPositionalArgs = args => {
238
+ const {
239
+ cliArgs
240
+ } = args;
241
+ const positional = [];
242
+ for (let i = 0; i < cliArgs.length; i++) {
243
+ const arg = cliArgs[i];
244
+ if (arg === void 0) continue;
245
+ if (!arg.startsWith("--")) {
246
+ positional.push(arg);
247
+ continue;
248
+ }
249
+ if (arg.indexOf("=") > 2) continue;
250
+ const next = cliArgs[i + 1];
251
+ if (next !== void 0 && !next.startsWith("--")) i++;
252
+ }
253
+ return positional;
254
+ };
231
255
 
232
256
  //#endregion
233
257
  //#region src/cli-wrappers/index.ts
@@ -5671,7 +5695,7 @@ program.argument("[command]", "API command in kebab-case (e.g. list-actors)").ar
5671
5695
  const queryArgs = {};
5672
5696
  const bodyArgs = {};
5673
5697
  for (const [flagKey, val] of Object.entries(flags)) {
5674
- if (flagKey === "profile") continue;
5698
+ if (flagKey === "profile" || flagKey === "id") continue;
5675
5699
  const canonical = toCanonical(flagKey);
5676
5700
  const parsedValue = parseFlagValue(val);
5677
5701
  const pathParam = route.pathParams.find(p => {
@@ -5682,6 +5706,19 @@ program.argument("[command]", "API command in kebab-case (e.g. list-actors)").ar
5682
5706
  });
5683
5707
  if (pathParam) pathArgs[pathParam] = parsedValue;else if (queryParam) queryArgs[queryParam] = parsedValue;else bodyArgs[kebabToSnake(flagKey)] = parsedValue;
5684
5708
  }
5709
+ const positionalArgs = extractPositionalArgs({
5710
+ cliArgs: rawArgs
5711
+ });
5712
+ const idAlias = flags["id"] ?? positionalArgs[0];
5713
+ const solePathParam = route.pathParams.length === 1 && route.pathParams[0];
5714
+ if (idAlias !== void 0 && solePathParam && !(solePathParam in pathArgs)) pathArgs[solePathParam] = parseFlagValue(idAlias);
5715
+ const missingPathParams = route.pathParams.filter(p => {
5716
+ return !(p in pathArgs);
5717
+ });
5718
+ if (missingPathParams.length > 0) {
5719
+ console.error(`Missing required path parameter(s): ${missingPathParams.join(", ")}.\nProvide with --${missingPathParams[0]} <value>, --id <value>, or a positional argument: soat ${commandName} <id>`);
5720
+ process.exit(1);
5721
+ }
5685
5722
  const client = resolveClient(flags["profile"] ?? program.opts().profile);
5686
5723
  const serviceClass = resolveServiceClass(route.serviceClass);
5687
5724
  if (!serviceClass) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soat/cli",
3
- "version": "0.14.5",
3
+ "version": "0.14.7",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@inquirer/input": "^5.1.2",
@@ -8,7 +8,7 @@
8
8
  "@ttoss/logger": "^0.8.19",
9
9
  "commander": "^15.0.0",
10
10
  "js-yaml": "^5.2.1",
11
- "@soat/sdk": "0.14.5"
11
+ "@soat/sdk": "0.14.7"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@ttoss/config": "^1.37.17",