Skip to main content

Module model_cli

Module model_cli 

Source
Expand description

Generic model-driven CLI runner.

Drives an AnyTable from positional argv tokens — model name, ARN, field=value filters, [N] index selectors, and :relation traversals. Backend specifics (which names map to which tables, how ARNs are parsed, how records are rendered) are injected through the ModelFactory and Renderer traits.

§Token forms

  • arn:... — ARN; resolved via ModelFactory::for_arn; drops straight into single-record mode.
  • iam.user, iam.users — model name (singular drops into single mode, plural into list mode).
  • field=value or field="quoted value" — adds an equality condition. Multiple are ANDed.
  • [N] — selects the Nth record from a list (zero-indexed) and narrows the table to that record. Switches to single-record mode.
  • :relation — traverses a relation registered via with_many / with_one. Only allowed in single-record mode (so the deferred child query yields a single foreign-key value); switches to list mode for the child table.
  • =col1,col2,... — overrides the visible columns in list mode. Stays in effect for the rest of the run; later relation traversals reset it. The literal id resolves to the table’s id field at render time.

Glued forms are accepted: users[0], :members[0], name=foo[0], and =col1,col2[0] all split into a base token plus an index selector.

Enums§

Mode
Whether the current state is a list of records or a single record.

Traits§

ModelFactory
Resolves model identifiers (singular/plural names, ARNs) to AnyTables. Implemented per-backend.
Renderer
Backend hook for printing list and single-record results.

Functions§

run
Run a model-driven CLI.