Skip to main content

ssh_cli/cli/
scp_args.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// G-SFTP-R12: SCP clap surface extracted from cli/mod (SRP; parity with sftp_args).
3#![forbid(unsafe_code)]
4//! Clap types for `ssh-cli scp …` (regular files only).
5
6use super::SshAuthArgs;
7use clap::{ArgAction, Subcommand};
8
9/// Actions of the `scp` subcommand (regular files only; no `-r`).
10///
11/// Directory trees use [`super::SftpAction`] (`ssh-cli sftp … --recursive`).
12#[derive(Debug, Subcommand)]
13pub enum ScpAction {
14    /// Uploads a local file to the remote host (regular files only).
15    Upload {
16        /// Upload to every registered host (bounded concurrency).
17        #[arg(long, action = ArgAction::SetTrue, conflicts_with = "hosts")]
18        all: bool,
19        /// Comma-separated host subset (bounded fan-out).
20        #[arg(long, value_name = "LIST", conflicts_with = "all")]
21        hosts: Option<String>,
22        /// Paths: `VPS LOCAL REMOTE`, or `VPS LOCAL... REMOTE_DIR` (multi-file, one session),
23        /// or with `--all`/`--hosts`: `LOCAL REMOTE` (one file) or `LOCAL... REMOTE_DIR` (multi-file × fleet).
24        #[arg(required = true, num_args = 2.., value_names = ["VPS", "LOCAL", "REMOTE"])]
25        target: Vec<String>,
26        /// SSH authentication overrides (password/key/passphrase).
27        #[command(flatten)]
28        auth: SshAuthArgs,
29        /// SSH timeout override in milliseconds (covers connect+transfer).
30        #[arg(long, value_name = "MS")]
31        timeout: Option<u64>,
32        /// JSON output (from global `--json`).
33        #[arg(from_global)]
34        json: bool,
35    },
36
37    /// Downloads a remote file to the local host (regular files only).
38    Download {
39        /// Download from every registered host (bounded concurrency).
40        #[arg(long, action = ArgAction::SetTrue, conflicts_with = "hosts")]
41        all: bool,
42        /// Comma-separated host subset (bounded fan-out).
43        #[arg(long, value_name = "LIST", conflicts_with = "all")]
44        hosts: Option<String>,
45        /// Paths: `VPS REMOTE LOCAL`, or `VPS REMOTE... LOCAL_DIR` (multi-file, one session),
46        /// or with `--all`/`--hosts`: `REMOTE LOCAL` (prefix) or `REMOTE... LOCAL_DIR` (per-host subdirs).
47        #[arg(required = true, num_args = 2.., value_names = ["VPS", "REMOTE", "LOCAL"])]
48        target: Vec<String>,
49        /// SSH authentication overrides (password/key/passphrase).
50        #[command(flatten)]
51        auth: SshAuthArgs,
52        /// SSH timeout override in milliseconds (covers connect+transfer).
53        #[arg(long, value_name = "MS")]
54        timeout: Option<u64>,
55        /// JSON output (from global `--json`).
56        #[arg(from_global)]
57        json: bool,
58    },
59}