Skip to main content

Module cli

Module cli 

Source
Expand description

Synthesizing clap commands from a cassette surface, and resolving them back into calls.

Every generated command is built here rather than derived, because the set is not known until a server has been asked. The shape deliberately matches a consumer’s hand-written surface — <noun> <method>, whatever shared flags the consumer decorates on, and the server’s JSON printed verbatim — so a cassette command is not visibly a second-class citizen next to a hand-written one.

§The consumer executes

This module stops at resolve_invocation, which turns a parsed match back into the Method it names and the Call to make. Executing the call and printing the response stay with the consumer: tapesctl reads its own --tapes-url flag (added through the augment decorator), builds its client, and prints the way its hand-written commands do.

Functions§

augment
Add a subcommand for every cassette on the surface.
call_for
Assemble the request for a matched method.
cassette_command
The subcommand for one cassette.
method_command
The subcommand for one method.
read_body
Resolve a --body value, which is either JSON or @<path>.
resolve_invocation
Resolve a matched cassette invocation back into the method it names and the call to make.