Skip to content

jasonkuhrt/oak

Repository files navigation

@wollybeard/oak

Type-safe CLI command definition and execution.

Installation

npm install @wollybeard/oak zod
# or
pnpm add @wollybeard/oak zod
# or
yarn add @wollybeard/oak zod

Note: zod v4 is a peer dependency.

Features

  • 🔒 Type-safe - Full TypeScript support with strong type inference
  • 🎨 Interactive prompts - Built-in prompt support for missing parameters
  • 🌍 Environment variables - Automatic environment variable parsing
  • 📝 Auto-generated help - Beautiful help documentation generated automatically
  • 🔌 Extensible - Support for custom schemas via extensions (Zod included)

Quick Start

import { Command } from '@wollybeard/oak'
import { Zod } from '@wollybeard/oak/extensions'
import { z } from 'zod/v4'

const args = Command.create()
  .use(Zod)
  .parameter('name', z.string())
  .parameter('age', z.number().optional())
  .parse()

console.log(`Hello ${args.name}!`)
if (args.age) console.log(`You are ${args.age} years old.`)

Examples

Check out the examples directory for more usage patterns:

Documentation

For detailed documentation, see the JSDoc comments in the source code.

Alternatives

  • OClif - Full-featured CLI framework
  • Commander - Popular CLI framework
  • Yargs - Traditional CLI parser
  • Arg - Simple argument parser

Migration from @molt/command

This package was previously published as @molt/command. To migrate:

  1. Update your imports:

    // Before
    import { Command } from '@molt/command'
    
    // After
    import { Command } from '@wollybeard/oak'
  2. Update your package.json:

    {
      "dependencies": {
        "@wollybeard/oak": "^0.9.0"
      }
    }

The API remains the same - only the package name has changed.

License

MIT

About

⚡️ CLI building blocks & framework for the TypeScript era.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •