Skip to content

generateSchema ​

Generated reference page for the generateSchema function export.

Signatures ​

ts
function generateSchema(schema: CLISchema, options?: JsonSchemaOptions, meta?: ExampleMeta): Record<string, unknown>;
ParameterTypeDescription
schemaCLISchemaThe CLI schema from CLIBuilder.schema.
optionsJsonSchemaOptions | undefinedGeneration options.
metaExampleMeta | undefinedProgram name/version for function-form examples; defaults to
the CLI schema's own name/version.

Members ​

Members ​

generateSchema ​

Generate a definition metadata document describing the CLI's structure.

Walks the full command tree and produces a plain JSON-serializable object representing all commands, subcommands, flags, args, and metadata. Non-serializable runtime values (parse functions, interactive resolvers) are omitted.

ts
(schema: CLISchema, options?: JsonSchemaOptions, meta?: ExampleMeta): Record<string, unknown>;

Examples ​

ts
const app = cli('myapp').version('1.0.0').command(deploy);
const definition = generateSchema(app.schema);
writeFileSync('cli-schema.json', JSON.stringify(definition, null, 2));

See Also ​

Released under the MIT License.