Skip to content

createCommandSchema ​

Generated reference page for the createCommandSchema function export.

Signatures ​

ts
function createCommandSchema(definition: CommandDefinition): CommandSchema;
ParameterTypeDescription
definitionCommandDefinitionCommand 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.

ts
(definition: CommandDefinition): CommandSchema;

Examples ​

ts
const schema = createCommandSchema({
  name: 'deploy',
  description: 'Ship the build',
  flags: { force: { kind: 'boolean' } },
  args: [{ name: 'target', schema: { kind: 'string' } }],
});

See Also ​

Released under the MIT License.