argsbarg 0.1.0 → 1.0.0

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/src/validate.ts CHANGED
@@ -28,7 +28,7 @@ export function cliValidateRoot(root: CliCommand): void {
28
28
  }
29
29
 
30
30
  // Check for reserved command names at root
31
- for (const child of root.children ?? []) {
31
+ for (const child of root.commands ?? []) {
32
32
  if (reservedCommandNames.includes(child.key)) {
33
33
  throw new CliSchemaValidationError(`Reserved command name: ${child.key}`);
34
34
  }
@@ -38,6 +38,7 @@ export function cliValidateRoot(root: CliCommand): void {
38
38
  walkCommand(root, true);
39
39
  }
40
40
 
41
+ /** Recursively validates a command node: handlers vs children, options, and positionals. */
41
42
  function walkCommand(cmd: CliCommand, isRoot: boolean = false): void {
42
43
  // Fallback only on root
43
44
  if (!isRoot && cmd.fallbackCommand !== undefined) {
@@ -55,7 +56,7 @@ function walkCommand(cmd: CliCommand, isRoot: boolean = false): void {
55
56
  );
56
57
  }
57
58
 
58
- if ((cmd.children ?? []).length > 0) {
59
+ if ((cmd.commands ?? []).length > 0) {
59
60
  if (cmd.handler !== undefined) {
60
61
  throw new CliSchemaValidationError(`Routing command must not set handler: ${cmd.key}`);
61
62
  }
@@ -67,7 +68,7 @@ function walkCommand(cmd: CliCommand, isRoot: boolean = false): void {
67
68
 
68
69
  // Check for duplicate child names
69
70
  const seenNames = new Set<string>();
70
- for (const child of cmd.children ?? []) {
71
+ for (const child of cmd.commands ?? []) {
71
72
  if (seenNames.has(child.key)) {
72
73
  throw new CliSchemaValidationError(`Duplicate command name: ${child.key}`);
73
74
  }
@@ -93,7 +94,7 @@ function walkCommand(cmd: CliCommand, isRoot: boolean = false): void {
93
94
  }
94
95
 
95
96
  // Validate positionals
96
- const positionals = (cmd.positionals ?? []).filter((p) => p.positional);
97
+ const positionals = cmd.positionals ?? [];
97
98
  for (const p of positionals) {
98
99
  if (p.argMin < 0) {
99
100
  throw new CliSchemaValidationError(`argMin must be >= 0 for positional ${cmd.key}/${p.name}`);
@@ -129,8 +130,8 @@ function walkCommand(cmd: CliCommand, isRoot: boolean = false): void {
129
130
  }
130
131
  }
131
132
 
132
- // Recurse into children
133
- for (const child of cmd.children ?? []) {
133
+ // Recurse into nested commands
134
+ for (const child of cmd.commands ?? []) {
134
135
  walkCommand(child, false);
135
136
  }
136
137
  }
package/bun.lock DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "lockfileVersion": 1,
3
- "configVersion": 1,
4
- "workspaces": {
5
- "": {
6
- "name": "bun-argsbarg",
7
- "devDependencies": {
8
- "@types/bun": "^1.3.12",
9
- },
10
- },
11
- },
12
- "packages": {
13
- "@types/bun": ["@types/bun@1.3.12", "", { "dependencies": { "bun-types": "1.3.12" } }, "sha512-DBv81elK+/VSwXHDlnH3Qduw+KxkTIWi7TXkAeh24zpi5l0B2kUg9Ga3tb4nJaPcOFswflgi/yAvMVBPrxMB+A=="],
14
-
15
- "@types/node": ["@types/node@25.6.0", "", { "dependencies": { "undici-types": "~7.19.0" } }, "sha512-+qIYRKdNYJwY3vRCZMdJbPLJAtGjQBudzZzdzwQYkEPQd+PJGixUL5QfvCLDaULoLv+RhT3LDkwEfKaAkgSmNQ=="],
16
-
17
- "bun-types": ["bun-types@1.3.12", "", { "dependencies": { "@types/node": "*" } }, "sha512-HqOLj5PoFajAQciOMRiIZGNoKxDJSr6qigAttOX40vJuSp6DN/CxWp9s3C1Xwm4oH7ybueITwiaOcWXoYVoRkA=="],
18
-
19
- "undici-types": ["undici-types@7.19.2", "", {}, "sha512-qYVnV5OEm2AW8cJMCpdV20CDyaN3g0AjDlOGf1OW4iaDEx8MwdtChUp4zu4H0VP3nDRF/8RKWH+IPp9uW0YGZg=="],
20
- }
21
- }