ostia 0.6.0 → 0.6.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli/flags.ts +12 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ostia",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Fast profiling and benchmarking for Bun.",
5
5
  "license": "MIT",
6
6
  "author": "Eric Liu (https://github.com/metonym)",
package/src/cli/flags.ts CHANGED
@@ -234,7 +234,7 @@ export function parseFlags<T extends object>(
234
234
  const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
235
235
  const name = eq > 0 ? arg.slice(0, eq) : arg;
236
236
  const flagDef = Object.hasOwn(flags, name) ? flags[name] : undefined;
237
- if (!flagDef || (eq > 0 && flagDef.spec.kind === "bool")) {
237
+ if (!flagDef) {
238
238
  if (arg.startsWith("-") || !positional) {
239
239
  throw new CliUsageError(
240
240
  `Unknown flag "${arg}" for "ostia ${command}".`,
@@ -269,9 +269,18 @@ export function parseFlags<T extends object>(
269
269
  set(dest, n);
270
270
  break;
271
271
  }
272
- case "bool":
273
- set(dest, spec.value);
272
+ case "bool": {
273
+ // --flag=true and --flag=false, as a script that passes a variable
274
+ // writes them; false inverts, so --no-color=false turns color on.
275
+ const raw = eq > 0 ? arg.slice(eq + 1) : "true";
276
+ if (raw !== "true" && raw !== "false") {
277
+ throw new CliUsageError(
278
+ `Invalid ${name} "${raw}": expected true or false`,
279
+ );
280
+ }
281
+ set(dest, raw === "true" ? spec.value : !spec.value);
274
282
  break;
283
+ }
275
284
  case "list":
276
285
  listAt(args, dest).push(value());
277
286
  break;