annotation Noir::OutputFormat

Overview

Marks an OutputBuilder subclass as the implementation of one -f/--format value.

@[Noir::OutputFormat(name: "json", description: "JSON", order: 30)]
class OutputBuilderJson < OutputBuilder

Noir::OutputFormats reads the catalog off the annotated classes, so this line is the only place a format's name, its help/noir list formats description, and the class that renders it are written down. Before it, those three facts lived in five hand-maintained lists (the dispatch case in NoirRunner#report, CliValidation::VALID_OUTPUT_FORMATS, the -f help text, and the zsh/bash/fish completion strings) that nothing linked together — a new format silently missed whichever ones the author forgot.

order decides where the format appears in help output and noir list formats; it has no runtime meaning. Values are spaced by 10 so a format can be slotted between two others without renumbering.

Builders that are not -f values (the diff renderer, the passive-scan section) carry no annotation and stay out of the registry.

Defined in:

models/output_builder.cr