{"_id":"@alt-stack/cli","_rev":"3-96956f32fa3d3bfc531cbb878f556a14","name":"@alt-stack/cli","dist-tags":{"latest":"1.6.2"},"versions":{"1.6.0":{"name":"@alt-stack/cli","version":"1.6.0","keywords":["cli","command-line","typescript","zod"],"author":"","license":"MIT","_id":"@alt-stack/cli@1.6.0","maintainers":[{"name":"aaltieri","email":"anthony@timebyping.com"}],"dist":{"shasum":"621d927712b90c9a1eeec1c931176569e2a08e16","tarball":"https://registry.npmjs.org/@alt-stack/cli/-/cli-1.6.0.tgz","fileCount":32,"integrity":"sha512-dhQKCy4yGvloRecxbUzL1M/JqcGJ1ULDoznZjyeIfNrn2/hlLkxGHL76LcHRjBkB2g9JQ3lq4lmyoLdluBOLww==","signatures":[{"sig":"MEQCIFF+9SQrYht5msPNIs9VWvfPpxm/aBMunm0xZ0wSdst0AiAhlpDKSB57Vn1lMvpy1+Z7hMQGdpdk/ubv4Q5simrJ5Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":329916},"main":"./dist/index.js","_from":"file:alt-stack-cli-1.6.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"test":"vitest","build":"tsup && node scripts/verify-dual-format.mjs","check-types":"tsc --noEmit"},"_npmUser":{"name":"aaltieri","email":"anthony@timebyping.com"},"_resolved":"/tmp/74c9660667920010beab0c4ef1172cec/alt-stack-cli-1.6.0.tgz","_integrity":"sha512-dhQKCy4yGvloRecxbUzL1M/JqcGJ1ULDoznZjyeIfNrn2/hlLkxGHL76LcHRjBkB2g9JQ3lq4lmyoLdluBOLww==","_npmVersion":"10.8.2","description":"Type-safe command-line applications with nested routing and Zod validation","directories":{},"_nodeVersion":"20.20.2","dependencies":{"@alt-stack/result":"1.6.0"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.0.0","tsup":"^8.0.0","oxlint":"^1.24.0","vitest":"^4.0.3","typescript":"^5.9.2","@types/node":"^22.0.0"},"peerDependencies":{"zod":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cli_1.6.0_1784714953734_0.5963823507745154","host":"s3://npm-registry-packages-npm-production"}},"1.6.1":{"name":"@alt-stack/cli","version":"1.6.1","keywords":["cli","command-line","typescript","zod"],"author":"","license":"MIT","_id":"@alt-stack/cli@1.6.1","maintainers":[{"name":"aaltieri","email":"anthony@timebyping.com"}],"dist":{"shasum":"46270bcd414e6cc7e907734bbfc0706561d9296a","tarball":"https://registry.npmjs.org/@alt-stack/cli/-/cli-1.6.1.tgz","fileCount":32,"integrity":"sha512-RWmEG3634tBqNMxqzutocaHstFGz4C340wZCTnVS37IEjnupY7R3M8q0VvPm/0d78AndwHQfDRk/fCOl64+upQ==","signatures":[{"sig":"MEYCIQCqhTzqWrVqDe5hn+RaDCmYiW+0IJrEjqYVKMBlWtNICwIhAJV4ipqMU8q0eV5uvIgNBDXvVWButmnxUSc0xP7gG0Vp","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":329972},"main":"./dist/index.js","_from":"file:alt-stack-cli-1.6.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"test":"vitest","build":"tsup && node scripts/verify-dual-format.mjs","check-types":"tsc --noEmit"},"_npmUser":{"name":"aaltieri","email":"anthony@timebyping.com"},"_resolved":"/tmp/b677044455de7816fc020c7175de920c/alt-stack-cli-1.6.1.tgz","_integrity":"sha512-RWmEG3634tBqNMxqzutocaHstFGz4C340wZCTnVS37IEjnupY7R3M8q0VvPm/0d78AndwHQfDRk/fCOl64+upQ==","_npmVersion":"10.8.2","description":"Type-safe command-line applications with nested routing and Zod validation","directories":{},"_nodeVersion":"20.20.2","dependencies":{"@alt-stack/result":"1.6.1"},"_hasShrinkwrap":false,"devDependencies":{"zod":"^4.0.0","tsup":"^8.0.0","oxlint":"^1.24.0","vitest":"^4.0.3","typescript":"^5.9.2","@types/node":"^22.0.0"},"peerDependencies":{"zod":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cli_1.6.1_1785249162776_0.4793194291577263","host":"s3://npm-registry-packages-npm-production"}},"1.6.2":{"name":"@alt-stack/cli","version":"1.6.2","description":"Type-safe command-line applications with nested routing and Zod validation","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"keywords":["cli","command-line","typescript","zod"],"author":"","license":"MIT","dependencies":{"@alt-stack/result":"1.6.2"},"peerDependencies":{"zod":"^4.0.0"},"devDependencies":{"@types/node":"^22.0.0","oxlint":"^1.24.0","tsup":"^8.0.0","typescript":"^5.9.2","vitest":"^4.0.3","zod":"^4.0.0"},"scripts":{"build":"tsup && node scripts/verify-dual-format.mjs","test":"vitest","check-types":"tsc --noEmit"},"_id":"@alt-stack/cli@1.6.2","_integrity":"sha512-JkXznGQCNf+KDCBXHrkaqvZZEaqlwJsRuaIGg4nXpz+2ZkVo3g8cpHzWsKJrvbML1eiOLsbMcPrlrcy3oLRrXw==","_resolved":"/tmp/39b6cf26a5b78e9c31c7487aff3274dd/alt-stack-cli-1.6.2.tgz","_from":"file:alt-stack-cli-1.6.2.tgz","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-JkXznGQCNf+KDCBXHrkaqvZZEaqlwJsRuaIGg4nXpz+2ZkVo3g8cpHzWsKJrvbML1eiOLsbMcPrlrcy3oLRrXw==","shasum":"e4068739dce5f43a3abb94e1b6112734a9231b60","tarball":"https://registry.npmjs.org/@alt-stack/cli/-/cli-1.6.2.tgz","fileCount":32,"unpackedSize":330028,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDY5PhHPzGUBSY+jYt0RxngRikCQbl11aRiHapqC31MJAIhAOqe74G5yeLurZphOuHmvCBQ1hS6hY+4VLajjrMJyHuf"}]},"_npmUser":{"name":"aaltieri","email":"anthony@timebyping.com"},"directories":{},"maintainers":[{"name":"aaltieri","email":"anthony@timebyping.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cli_1.6.2_1787164485502_0.440245962006639"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-22T10:09:13.576Z","modified":"2026-08-19T18:34:45.808Z","1.6.0":"2026-07-22T10:09:13.888Z","1.6.1":"2026-07-28T14:32:42.924Z","1.6.2":"2026-08-19T18:34:45.654Z"},"license":"MIT","keywords":["cli","command-line","typescript","zod"],"description":"Type-safe command-line applications with nested routing and Zod validation","maintainers":[{"name":"aaltieri","email":"anthony@timebyping.com"}],"readme":"# `@alt-stack/cli`\n\n`@alt-stack/cli` builds type-safe command-line applications from immutable procedures and nested routers. Arguments and options are parsed with Zod, middleware can refine invocation context, and handlers return `Result` values.\n\n## Install\n\n```bash\npnpm add @alt-stack/cli zod\n```\n\n## Define and run a nested CLI\n\n```typescript\nimport { createCli, initCli, ok, runCli } from \"@alt-stack/cli\";\nimport { randomUUID } from \"node:crypto\";\nimport { z } from \"zod\";\n\ninterface AppContext {\n  requestId: string;\n}\n\nconst t = initCli<AppContext>();\n\nconst appRouter = t.router({\n  users: t.router(\n    {\n      create: t.procedure\n        .description(\"Create a user\")\n        .args({\n          name: t.argument(z.string().min(1), { metavar: \"name\" }),\n        })\n        .options({\n          role: t.option(z.enum([\"admin\", \"member\"]).default(\"member\"), {\n            short: \"r\",\n            metavar: \"role\",\n          }),\n          notify: t.flag({ short: \"n\" }),\n        })\n        .command(({ input, ctx }) => {\n          return ok({\n            requestId: ctx.requestId,\n            name: input.args.name,\n            role: input.options.role,\n            notify: input.options.notify,\n          });\n        }),\n    },\n    { description: \"Manage users\" },\n  ),\n});\n\nconst cli = createCli({\n  name: \"acme\",\n  version: \"1.0.0\",\n  description: \"Acme administration tools\",\n  router: appRouter,\n  createContext: () => ({ requestId: randomUUID() }),\n});\n\nasync function main(): Promise<void> {\n  const exitCode = await runCli(cli, {\n    argv: process.argv.slice(2),\n    stdout: process.stdout,\n    stderr: process.stderr,\n    formatValue: (value) => JSON.stringify(value, null, 2),\n  });\n  process.exitCode = exitCode;\n}\n\nvoid main();\n```\n\nThis produces commands such as:\n\n```bash\nacme users create Ada --role admin --notify\nacme users create --help\nacme --version\n```\n\n`createCli().execute(argv)` has no ambient process dependency. It returns one of `executed`, `help`, `version`, `usage-error`, or `command-error`, so applications can embed the same CLI in tests or another host without intercepting output or exits. `runCli` is the optional terminal renderer and writes only to the streams supplied by the caller.\n\nThe object returned by `createContext` is the invocation-scoped context container and must be a plain object (standard or null prototype). Put class-based clients, loggers, and other service instances in properties of that container rather than returning a class instance as the container itself.\n\nSee the [CLI quickstart](../../apps/docs/docs/cli/quickstart.md), [common patterns](../../apps/docs/docs/cli/common-patterns.md), and [API documentation](../../apps/docs/docs/cli/api.md).\n","readmeFilename":"README.md"}