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