Skip to main content

Generated commands

Most of what you can do with the apimetrics CLI is not hard-coded into the binary. The CLI is a fork of Restish: at startup it loads the APIContext OpenAPI description from its configured server and turns each API operation into its own CLI command.

That is why you can run commands like:

apimetrics list-monitors
apimetrics create-monitor
apimetrics get-result <result-id>

even though none of those are written into the binary's source. Each one corresponds to an operation in the OpenAPI description.

How generation works​

  1. On startup the CLI fetches (and caches) the OpenAPI description from the configured endpoint.
  2. For every operation in that description, it registers a cobra command, deriving the command name, flags, and input/response schemas from the operation.
  3. Those generated commands sit alongside the always-present built-in commands (login, project select, bulk).

The description is cached locally (in the cache directory described in the CLI overview), so subsequent runs are fast.

Auto-authentication​

Generated commands talk to the live API, so they need credentials. You do not have to log in first — when a command needs authentication and none is cached, the CLI automatically triggers the login flow (OAuth 2.0 authorization-code + PKCE by default). After that it remembers your credentials and active project.

The command set varies​

Because the commands come from the loaded OpenAPI description, the available set is not fixed. It depends on:

  • the configured endpoint the CLI points at,
  • the version of the API description served there, and
  • your account tier / role, which can gate which operations are exposed.

Any snapshot of the command list (including the captured fixture used to write these docs) is therefore only one point-in-time view, not a permanent contract.

Discovering what is available​

The authoritative list for your setup is always the binary itself. Use --help:

# List every command available to you, grouped by category
apimetrics --help

# Inspect a single generated command: its flags and request/response schema
apimetrics list-monitors --help

Combine with the global flags — for example -o json for machine-readable output:

apimetrics list-monitors -o json

See also​