generate_command_tree

Function generate_command_tree 

Source
pub fn generate_command_tree(spec: &CachedSpec) -> Command
Expand description

Generates a dynamic clap command tree from a cached OpenAPI specification.

This function creates a hierarchical command structure based on the OpenAPI spec:

  • Root command: “api” (CLI_ROOT_COMMAND)
  • Tag groups: Operations are grouped by their tags (e.g., “users”, “posts”)
  • Operations: Individual API operations as subcommands under their tag group

§Arguments

  • spec - The cached OpenAPI specification
  • experimental_flags - Whether to use flag-based syntax for all parameters

§Returns

A clap Command configured with all operations from the spec

§Example

For an API with a “users” tag containing “getUser” and “createUser” operations:

api users get-user <args>
api users create-user <args>