createCommandSchema
Generated reference page for the createCommandSchema function export.
- Import:
@kjanat/dreamcli - Export kind: function
- Declared in:
src/core/schema/command.ts - Source link:
src/core/schema/command.ts:816
Signatures
function createCommandSchema(definition: CommandDefinition): CommandSchema;| Parameter | Type | Description |
|---|---|---|
definition | CommandDefinition | Command name plus optional flags, args, and subcommands. |
Members
Members
createCommandSchema
Create a CommandSchema from a plain definition object.
Most consumers should prefer command(), which returns a CommandBuilder with type inference. createCommandSchema() is the low-level escape hatch for tooling that composes schemas as data.
Flags, args, and subcommands are normalized recursively, so an already-built schema fed back in produces a deep-equal schema.
Flag spellings are checked across the whole tree, so a definition whose names, aliases, or negated spellings collide with each other or with a propagated ancestor flag is rejected here. Both flags still parse under their canonical names, so what a collision costs is the shared spelling. Help advertises it on both flags and the parser answers it with one of them. Args go through the same invariants CommandBuilder.arg enforces. These are the checks the CommandBuilder applies as flags, args, and subcommands are registered.
(definition: CommandDefinition): CommandSchema;Examples
const schema = createCommandSchema({
name: 'deploy',
description: 'Ship the build',
flags: { force: { kind: 'boolean' } },
args: [{ name: 'target', schema: { kind: 'string' } }],
});