| name | server-url-templating-api-custom-commands |
| description | How to author custom commands for the server-url-templating-api CLI using the co-generated SDK. |
Custom Commands for server-url-templating-api
Overview
The server-url-templating-api 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/server-url-templating-api/custom.rs ← Your command handlers (protected by .fernignore)
cli/server-url-templating-api/sdk.rs ← Generated bridge: client() + block_on()
cli/server-url-templating-api/main.rs ← Generated entrypoint (calls custom::register)
server-url-templating-api-sdk/ ← Co-generated typed SDK crate
server-url-templating-api-types/ ← Co-generated typed model crate
Adding a Custom Command
1. Edit cli/server-url-templating-api/custom.rs
This file is protected by .fernignore — fern generate will never
overwrite it. Register commands in the register() function:
use server_url_templating_api_sdk::api::*;
pub fn register(app: CliApp) -> CliApp {
let app = app.command(
clap::Command::new("my-command")
.about()
.(clap::Arg::().()),
|matches, ctx| {
= matches.get_one::<>().();
= super::sdk::(ctx);
= super::sdk::(
client.resource.(id),
)?;
(, serde_json::(&result).());
(())
},
);
app
}