thrift_generator_cli (thrift_generator v0.7.0)

View Source

Command-line front end (escript entry point).

thrift_generator <file.thrift> [-o <out_dir>] [--repr record|map|native]
    [--union-type record|sum] [--set list|sets|ordset] [--typedef-type alias|nominal] [--check]
thrift_generator generate <file.thrift> [same options]

Argument parsing rides on the stdlib argparse module (usage/help included); generate stays accepted as an optional subcommand — the file operand selects the action. Runs the full pipeline (load with includes, semantic analysis, emit) and writes the generated Erlang sources to out_dir (default: the current directory). The four option flags each pick the generated flavor for definitions without an explicit annotation of their own: --repr the value representation (erl.struct_type), --union-type the union representation (erl.union_type), --set the in-process set implementation (erl.set) and --typedef-type the typedef flavor (erl.type); a file-wide namespace default overrides the flag for its file. --check verifies instead of writing: every generated artifact must already exist in out_dir with the exact content this input would produce — drift (missing or stale files) exits 1, so the flag works as a CI freshness gate.

Errors render as rebar3/elp-style source excerpts (the offending line under a gutter, a ╰── marker naming the problem); --compact-errors switches to one-line path:line[:column]: message entries. The rendering is shared with the rebar3 plugin through format_error/1.

Summary

Functions

format_error(Reason)

main(RawArgs)

-spec main([string()]) -> no_return().