Skip to main content

twc_rs/cli/
ssh.rs

1// SPDX-FileCopyrightText: 2026 RAprogramm <andrey.rozanov.vl@gmail.com>
2// SPDX-License-Identifier: MIT
3
4//! SSH key subcommands.
5
6use clap::Subcommand;
7
8/// SSH key subcommands.
9#[derive(Subcommand, Debug)]
10pub enum SshCommands {
11    /// List all SSH keys.
12    List,
13    /// Add an SSH key from a file or stdin.
14    Add {
15        /// Human-readable name for the key.
16        #[arg(long)]
17        name: String,
18
19        /// Path to the public key file. Reads from stdin if omitted.
20        #[arg(long)]
21        file: Option<String>,
22
23        /// Mark this key as default for new servers.
24        #[arg(long)]
25        default: bool
26    },
27    /// Delete an SSH key by ID.
28    Delete {
29        /// SSH key ID.
30        #[arg(long)]
31        id: i32
32    },
33    /// Show detailed information about an SSH key.
34    Info {
35        /// SSH key ID.
36        #[arg(long)]
37        id: i32
38    },
39    /// Edit an SSH key's name and/or default flag.
40    Edit {
41        /// SSH key ID.
42        #[arg(long)]
43        id:      i32,
44        /// New name for the key.
45        #[arg(long)]
46        name:    Option<String>,
47        /// Mark this key as default for new servers.
48        #[arg(long)]
49        default: Option<bool>
50    },
51    /// Attach existing SSH key(s) to a cloud server.
52    Attach {
53        /// Target server ID.
54        #[arg(long)]
55        server: i32,
56        /// SSH key ID to attach. Repeat to attach several at once.
57        #[arg(long = "key")]
58        key:    Vec<i32>
59    },
60    /// Detach an SSH key from a cloud server.
61    Detach {
62        /// Target server ID.
63        #[arg(long)]
64        server: i32,
65        /// SSH key ID to detach.
66        #[arg(long = "key")]
67        key:    i32
68    }
69}