Skip to content

Allow applications to register custom CLI output formats #510

Description

@kamilio

Summary

Toolcraft's generated --output control is hard-coded to rich, md/markdown, and json. Applications cannot register an additional renderer name such as compact even when the command already has a suitable renderer.

Reproduction

await runCLI(root, { controls: { output: true } });
my-cli query --output compact
# Invalid value for --output. Expected rich, md, markdown, or json.

There is no controls.output.formats / renderer registry hook to accept compact and dispatch it to an application renderer.

Requested change

  • Let applications register named output formats and renderer callbacks.
  • Include registered names in generated help, validation, completion, and error suggestions.
  • Preserve the built-in rich, md, and json formats.
  • Expose the selected output format to command renderers without requiring an application parameter.
  • Add an in-process test harness assertion for exact stdout bytes from custom formats.

Downstream impact

homey-sync query commands need a token-minimal TSV/JSONL mode selected as --output compact. The current workaround rewrites argv before runCLI, maps compact to the Markdown transport, injects hidden command parameters, and returns exact text through each Markdown renderer. This is covered by CLI integration tests, but it duplicates routing logic that belongs in Toolcraft and makes custom formats unavailable to other generated surfaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions