specli 0.0.30 → 0.0.31

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/cli/main.js +59 -0
  2. package/package.json +1 -1
package/dist/cli/main.js CHANGED
@@ -45,6 +45,7 @@ export async function main(argv, options = {}) {
45
45
  .option("--api-key <key>", "API key value")
46
46
  .option("--json", "Machine-readable output")
47
47
  .showHelpAfterError();
48
+ program.addHelpText("after", `\nAgent workflow:\n 1) ${options.cliName ?? "specli"} __schema --json --min\n 2) ${options.cliName ?? "specli"} <resource> --help\n 3) ${options.cliName ?? "specli"} <resource> <action> --help\n`);
48
49
  // If user asks for help and we have no embedded spec and no --spec, show minimal help.
49
50
  const spec = getArgValue(argv, "--spec");
50
51
  const wantsHelp = hasAnyArg(argv, ["-h", "--help"]);
@@ -177,6 +178,10 @@ export async function main(argv, options = {}) {
177
178
  process.stdout.write(`- ${program.name()} ${op.resource} ${op.action}${args}\n`);
178
179
  }
179
180
  }
181
+ process.stdout.write("\nTip: explore required flags with --help at each level:\n" +
182
+ `- ${program.name()} --help\n` +
183
+ `- ${program.name()} <resource> --help\n` +
184
+ `- ${program.name()} <resource> <action> --help\n`);
180
185
  });
181
186
  addGeneratedCommands(program, {
182
187
  servers: ctx.servers,
@@ -189,5 +194,59 @@ export async function main(argv, options = {}) {
189
194
  auth: options.auth,
190
195
  },
191
196
  });
197
+ if (argv.length <= 2) {
198
+ program.outputHelp();
199
+ return;
200
+ }
201
+ const args = argv.slice(2);
202
+ const flagWithValue = new Set([
203
+ "--spec",
204
+ "--server",
205
+ "--server-var",
206
+ "--auth",
207
+ "--bearer-token",
208
+ "--oauth-token",
209
+ "--username",
210
+ "--password",
211
+ "--api-key",
212
+ ]);
213
+ const boolFlags = new Set(["--json"]);
214
+ const passthroughFlags = new Set(["-h", "--help", "-v", "--version"]);
215
+ let hasSubcommand = false;
216
+ let onlyKnownGlobals = true;
217
+ for (let i = 0; i < args.length; i++) {
218
+ const a = args[i];
219
+ if (!a)
220
+ continue;
221
+ if (passthroughFlags.has(a))
222
+ break;
223
+ if (boolFlags.has(a))
224
+ continue;
225
+ if (flagWithValue.has(a)) {
226
+ i++;
227
+ continue;
228
+ }
229
+ if (a.startsWith("--") && a.includes("=")) {
230
+ const key = a.slice(0, a.indexOf("="));
231
+ if (!flagWithValue.has(key) &&
232
+ !boolFlags.has(key) &&
233
+ !passthroughFlags.has(key)) {
234
+ onlyKnownGlobals = false;
235
+ }
236
+ continue;
237
+ }
238
+ if (a.startsWith("--") || a.startsWith("-")) {
239
+ onlyKnownGlobals = false;
240
+ continue;
241
+ }
242
+ hasSubcommand = true;
243
+ break;
244
+ }
245
+ if (!hasSubcommand &&
246
+ onlyKnownGlobals &&
247
+ !hasAnyArg(argv, ["-h", "--help", "-v", "--version"])) {
248
+ program.outputHelp();
249
+ return;
250
+ }
192
251
  await program.parseAsync(argv);
193
252
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specli",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
4
4
  "description": "Run any OpenAPI spec as a CLI. Built for Agents.",
5
5
  "repository": {
6
6
  "type": "git",