@silkweave/cli
v1.6.0
Published
Silkweave CLI Adapter
Readme
@silkweave/cli
CLI adapter for Silkweave - turn your actions into a complete command-line application with help text, option parsing, and styled terminal output via clack.
Install
pnpm add @silkweave/core @silkweave/cliUsage
import { silkweave } from '@silkweave/core'
import { cli } from '@silkweave/cli'
import { GreetAction } from './actions/greet.js'
await silkweave({ name: 'mytool', description: 'My CLI Tool', version: '1.0.0' })
.adapter(cli())
.action(GreetAction)
.start()$ mytool greet --name "World" --enthusiastic
◇ mytool - greet
ℹ HELLO, WORLD!!!How Zod Types Map to CLI Options
| Zod Type | CLI Representation |
|----------|-------------------|
| z.string() | --option-name <string> |
| z.number() | --option-name <number> |
| z.boolean() | --option-name / --no-option-name |
| z.enum([...]) | --option-name <choice> with choices validation |
| z.record() | --option-name <json> |
| .default(value) | Sets the default in help text |
| .describe('...') | Sets the option description |
Field names are automatically converted to kebab-case. Action names become subcommands.
Positional Arguments
Use the args property on an action to promote fields to positional arguments:
const DeployAction = createAction({
name: 'deploy',
input: z.object({
environment: z.string(),
dryRun: z.boolean().default(false)
}),
args: ['environment'],
// ...
})$ mytool deploy production --dry-runSee Also
- Silkweave README - Full documentation
@silkweave/core- Core library
