| name | oauth-client-credentials-openapi-custom-commands |
| description | How to author custom commands for the oauth-client-credentials-openapi CLI using the co-generated SDK. |
Custom Commands for oauth-client-credentials-openapi
Overview
The oauth-client-credentials-openapi CLI supports user-authored custom commands that are
compiled into the binary alongside the auto-generated API commands.
Custom commands get a fully-wired SDK client that inherits the CLI's
auth, retries, TLS, base URL, and global headers — zero configuration required.
Architecture
cli/oauth-client-credentials-openapi/custom.rs ← Your command handlers (protected by .fernignore)
cli/oauth-client-credentials-openapi/sdk.rs ← Generated bridge: client() + block_on()
cli/oauth-client-credentials-openapi/main.rs ← Generated entrypoint (calls custom::register)
oauth-client-credentials-openapi-sdk/ ← Co-generated typed SDK crate
oauth-client-credentials-openapi-types/ ← Co-generated typed model crate
Adding a Custom Command
1. Edit cli/oauth-client-credentials-openapi/custom.rs
This file is protected by .fernignore — fern generate will never
overwrite it. Register commands in the register() function:
use oauth_client_credentials_openapi_sdk::api::*;
pub fn register(app: CliApp) -> CliApp {
let app = app.command(
clap::Command::new("get")
.()
.(clap::Arg::().())
,
|matches, ctx| {
= matches.get_one::<>().();
= super::sdk::(ctx);
= super::sdk::(
client.plants.(plant_id),
)?;
(, serde_json::(&result).());
(())
},
);
app
}