1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-License-Identifier: MIT OR Apache-2.0
//! # ssh-cli
//!
//! Full-stack Rust CLI that gives an LLM (Claude Code, Cursor, Windsurf) the ability
//! to operate remote servers over SSH in a subprocess flow via stdin/stdout.
//!
//! ## Modules
//!
//! | Module | Responsibility |
//! |-----------------|---------------------------------------------------------------|
//! | `cli` | Clap derive argument definitions and dispatcher |
//! | `vps` | CRUD and persistence of VPS records (XDG + TOML + 0o600) |
//! | `secrets` | Primary key and default at-rest encryption (ChaCha20-Poly1305)|
//! | `ssh` | Real one-shot SSH client via `russh` (password/key, TOFU) |
//! | `i18n` | Internationalization with bilingual `Message` enum |
//! | `locale` | OS locale detection and resolution |
//! | `platform` | Platform adjustments (Windows UTF-8, TTY detection) |
//! | `masking` | Unicode-safe masking of sensitive values |
//! | `errors` | Structured error types via `thiserror` |
//! | `output` | Sole module authorized for `println!` (CRUD formatting) |
//! | `paths` | Path validation and normalization (anti-traversal, NFC) |
//! | `signals` | Ctrl+C handler with cancellation flag via `AtomicBool` |
//! | `terminal` | TTY detection and color choice via `termcolor` |
//!
//! ## Entry point
//!
//! The public [`run`] function is the entry point called by `main.rs`.
use Result;
/// Runs ssh-cli from the command-line arguments.
///
/// Entry point called by `main.rs`. It:
/// 1. Registers the Ctrl+C handler for graceful cancellation.
/// 2. Initializes the platform (Windows UTF-8 code page, TTY detection).
/// 3. Parses arguments via clap.
/// 4. Initializes logging via `tracing-subscriber`.
/// 5. Initializes terminal color configuration.
/// 6. Initializes i18n with the detected language.
/// 7. Dispatches to the appropriate subcommand (`vps`, `connect`, `exec`, `sudo-exec`, `scp`, `tunnel`).
pub async