link_assistant_router/cli/client_ops.rs
1//! `clients` subcommands.
2//!
3//! Split from `cli.rs` to keep that file within the repository's 1000-line
4//! limit.
5
6use clap::Subcommand;
7
8use crate::clients::ClientKind;
9
10#[derive(Debug, Subcommand)]
11pub enum ClientOp {
12 /// List supported clients and their local installation/configuration state.
13 List {
14 /// Emit JSON instead of the table (issue #314).
15 #[arg(long)]
16 json: bool,
17 },
18 /// Merge this router into a client's user configuration.
19 ///
20 /// `router configure <client>` is the name for this, and the one that
21 /// follows the server selection. `create` and `add` are accepted here too
22 /// (issues #296, #314).
23 #[command(alias = "create", alias = "add")]
24 Setup {
25 #[arg(value_enum)]
26 client: ClientKind,
27 /// Existing router token. Prefer `--token-stdin` or
28 /// `LINK_ASSISTANT_ROUTER_TOKEN` over argv, which is visible in shell
29 /// history and process listings.
30 #[arg(long, hide_env_values = true, conflicts_with = "token_stdin")]
31 token: Option<String>,
32 /// Read an existing router token as one line from standard input.
33 #[arg(long, conflicts_with = "token")]
34 token_stdin: bool,
35 /// Router URL reachable from the client.
36 ///
37 /// Spelled `--server` like everywhere else the router's own URL is
38 /// named; `--base-url` means the *upstream's* URL in `providers add`,
39 /// so one flag referred to two different machines depending on the
40 /// family (issue #314). The old spelling is still accepted.
41 #[arg(long = "server", alias = "base-url", value_name = "URL")]
42 base_url: Option<String>,
43 /// Private management origin when it differs from the client-facing
44 /// inference origin.
45 #[arg(long, value_name = "URL", requires = "base_url")]
46 management_server: Option<String>,
47 /// Lifetime of an automatically minted token.
48 #[arg(long, default_value_t = 24)]
49 ttl_hours: i64,
50 },
51 /// Show the effective client integration with secrets redacted.
52 Show {
53 #[arg(value_enum)]
54 client: ClientKind,
55 /// Accepted for symmetry with `list`: `show` already emits JSON, so
56 /// this changes nothing (issue #314). A script should not have to know
57 /// which verb of a family takes the flag.
58 #[arg(long)]
59 json: bool,
60 },
61 /// Remove only settings managed by this router.
62 ///
63 /// `delete` and `revoke` are accepted too (issue #314).
64 #[command(alias = "delete", alias = "revoke")]
65 Remove {
66 #[arg(value_enum)]
67 client: ClientKind,
68 /// Also revoke a token that was supplied by the operator instead of
69 /// minted by `clients setup`. Off by default because the same token
70 /// is often shared with other machines.
71 #[arg(long)]
72 revoke_supplied: bool,
73 /// Delete the local settings even when the managed token could not be
74 /// revoked. The credential stays usable until it expires.
75 #[arg(long)]
76 force: bool,
77 },
78 /// Reconcile routing-critical client settings with the selected Router.
79 Repair {
80 /// One client to repair. Use --all to inspect or repair every client.
81 #[arg(value_enum, required_unless_present = "all")]
82 client: Option<ClientKind>,
83 /// Inspect or repair every documented client independently.
84 #[arg(long, conflicts_with = "client")]
85 all: bool,
86 /// Print the secret-free plan without network access or filesystem writes.
87 #[arg(long)]
88 dry_run: bool,
89 /// Emit stable machine-readable output.
90 #[arg(long)]
91 json: bool,
92 /// Restore an earlier repair snapshot after verifying no later edits exist.
93 #[arg(
94 long,
95 value_name = "BACKUP_ID",
96 requires = "client",
97 conflicts_with_all = ["all", "dry_run"]
98 )]
99 rollback: Option<String>,
100 },
101 /// Make a real request using the client's configured URL and token variable.
102 ///
103 /// The probe is deliberately the cheapest the dialect accepts: a 64-token
104 /// budget, reasoning at the lowest tier, and a two-word prompt. It still
105 /// costs a request against the subscription, because proving the route
106 /// works means using it (issues #275, #309).
107 Doctor {
108 #[arg(value_enum)]
109 client: ClientKind,
110 },
111}