@xyd-js/opencli
v0.0.0-build-f0c10f6-20260703195526
Published
OpenCLI core model and helpers (shared by opencli-remark and the openapi2opencli / opencli2* generators)
Readme
@xyd-js/opencli
The OpenCLI core for xyd: the data model plus the pure spec/loader/generator
helpers shared by @xyd-js/opencli-remark (CLI docs) and the
openapi2opencli / opencli2* code generators.
What's here
- The model (
src/types.ts) — generated fromopencli-spec.json, the OpenCLI JSON Schema.OpencliSpecJson,Command,Option,Argument,Arity,ExitCode,Conventions,CliInfo, … - The
x-openapiextension — an xyd addition to the schema that binds an OpenCLI document back to its OpenAPI/HTTP origin so generators can build real requests:XOpenApiRooton the spec root —servers,security(with anenvVarhint).XOpenApiCommandon each command —method,path,contentType,security,params[](each maps a CLIargument:/option:fromtoken to an HTTP param), andbody(flatten|json|multipart, per-property field mappings).
- Helpers
loadOpencliSpec(source, { cwd? })— load a spec from a file path or URL.findCommand(spec, "a b c")— resolve a command by path (alias-aware).generateUsage / generateDescription / generateArguments / generateOptions / generateCommands / generateFlags— render command docs (code or list style).
Regenerating the model
After editing opencli-spec.json:
pnpm --filter @xyd-js/opencli generate:types # json2ts → src/types.ts (do not hand-edit)
pnpm --filter @xyd-js/opencli build