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        /// Named source slot (repeatable). Pairs with `--dest`; never remaps a positional.
23        #[arg(long = "src", value_name = "PATH", action = ArgAction::Append)]
24        src: Vec<String>,
25        /// Named destination slot. Always a directory, whatever the source count.
26        #[arg(long = "dest", value_name = "DIR")]
27        dest: Option<String>,
28        /// Paths: `VPS LOCAL REMOTE`, or `VPS LOCAL... REMOTE_DIR` (multi-file, one session),
29        /// or with `--all`/`--hosts`: `LOCAL REMOTE` (one file only — more sources need `--src`/`--dest`).
30        #[arg(num_args = 0.., value_names = ["VPS", "LOCAL", "REMOTE"])]
31        target: Vec<String>,
32        /// SSH authentication overrides (password/key/passphrase).
33        #[command(flatten)]
34        auth: SshAuthArgs,
35        /// SSH timeout override in milliseconds (covers connect+transfer).
36        #[arg(long, value_name = "MS")]
37        timeout: Option<u64>,
38        /// JSON output (from global `--json`).
39        #[arg(from_global)]
40        json: bool,
41    },
42
43    /// Downloads a remote file to the local host (regular files only).
44    Download {
45        /// Download from every registered host (bounded concurrency).
46        #[arg(long, action = ArgAction::SetTrue, conflicts_with = "hosts")]
47        all: bool,
48        /// Comma-separated host subset (bounded fan-out).
49        #[arg(long, value_name = "LIST", conflicts_with = "all")]
50        hosts: Option<String>,
51        /// Named source slot (repeatable). Pairs with `--dest`; never remaps a positional.
52        #[arg(long = "src", value_name = "PATH", action = ArgAction::Append)]
53        src: Vec<String>,
54        /// Named destination slot. Always a directory, whatever the source count.
55        #[arg(long = "dest", value_name = "DIR")]
56        dest: Option<String>,
57        /// Paths: `VPS REMOTE LOCAL`, or `VPS REMOTE... LOCAL_DIR` (multi-file, one session),
58        /// or with `--all`/`--hosts`: `REMOTE LOCAL` (one file only — more sources need `--src`/`--dest`).
59        #[arg(num_args = 0.., value_names = ["VPS", "REMOTE", "LOCAL"])]
60        target: Vec<String>,
61        /// SSH authentication overrides (password/key/passphrase).
62        #[command(flatten)]
63        auth: SshAuthArgs,
64        /// SSH timeout override in milliseconds (covers connect+transfer).
65        #[arg(long, value_name = "MS")]
66        timeout: Option<u64>,
67        /// JSON output (from global `--json`).
68        #[arg(from_global)]
69        json: bool,
70    },
71}