Skip to main content

ssh_cli/cli/
sftp_args.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// G-SFTP-07 / G-SFTP-12: SFTP clap surface extracted from cli/mod (SRP).
3#![forbid(unsafe_code)]
4//! Clap types for `ssh-cli sftp …`.
5
6use super::SshAuthArgs;
7use clap::{ArgAction, Subcommand};
8
9/// Actions of the `sftp` subcommand (SFTP v3 subsystem).
10#[derive(Debug, Subcommand)]
11pub enum SftpAction {
12    /// Uploads a local file or tree to the remote host via SFTP.
13    Upload {
14        /// Upload to every registered host (bounded concurrency).
15        #[arg(long, action = ArgAction::SetTrue, conflicts_with = "hosts")]
16        all: bool,
17        /// Comma-separated host subset (bounded fan-out).
18        #[arg(long, value_name = "LIST", conflicts_with = "all")]
19        hosts: Option<String>,
20        /// Named source slot (repeatable). Pairs with `--dest`; never remaps a positional.
21        #[arg(long = "src", value_name = "PATH", action = ArgAction::Append)]
22        src: Vec<String>,
23        /// Named destination slot. Always a directory, whatever the source count.
24        #[arg(long = "dest", value_name = "DIR")]
25        dest: Option<String>,
26        /// Paths: `VPS LOCAL REMOTE`, multi-file `VPS LOCAL... REMOTE_DIR`, or fleet `--all`/`--hosts` `LOCAL REMOTE`.
27        #[arg(num_args = 0.., value_names = ["VPS", "LOCAL", "REMOTE"])]
28        target: Vec<String>,
29        /// Recursively upload a local directory tree (no symlink follow).
30        #[arg(short = 'r', long, action = ArgAction::SetTrue)]
31        recursive: bool,
32        /// SSH authentication overrides.
33        #[command(flatten)]
34        auth: SshAuthArgs,
35        /// Timeout override in milliseconds (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 or tree to the local host via SFTP.
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`, multi-file forms, or fleet `--all`/`--hosts` `REMOTE LOCAL`.
58        #[arg(num_args = 0.., value_names = ["VPS", "REMOTE", "LOCAL"])]
59        target: Vec<String>,
60        /// Recursively download a remote directory tree (no symlink follow).
61        #[arg(short = 'r', long, action = ArgAction::SetTrue)]
62        recursive: bool,
63        /// SSH authentication overrides.
64        #[command(flatten)]
65        auth: SshAuthArgs,
66        /// Timeout override in milliseconds (connect+transfer).
67        #[arg(long, value_name = "MS")]
68        timeout: Option<u64>,
69        /// JSON output (from global `--json`).
70        #[arg(from_global)]
71        json: bool,
72    },
73
74    /// Lists a remote directory.
75    Ls {
76        /// VPS name.
77        vps_name: String,
78        /// Remote directory path.
79        remote: String,
80        /// SSH authentication overrides.
81        #[command(flatten)]
82        auth: SshAuthArgs,
83        /// Timeout override in milliseconds.
84        #[arg(long, value_name = "MS")]
85        timeout: Option<u64>,
86        /// JSON output (from global `--json`).
87        #[arg(from_global)]
88        json: bool,
89    },
90
91    /// Creates a remote directory.
92    Mkdir {
93        /// VPS name.
94        vps_name: String,
95        /// Remote directory path.
96        remote: String,
97        /// SSH authentication overrides.
98        #[command(flatten)]
99        auth: SshAuthArgs,
100        /// Timeout override in milliseconds.
101        #[arg(long, value_name = "MS")]
102        timeout: Option<u64>,
103        /// JSON output (from global `--json`).
104        #[arg(from_global)]
105        json: bool,
106    },
107
108    /// Removes an empty remote directory.
109    Rmdir {
110        /// VPS name.
111        vps_name: String,
112        /// Remote directory path.
113        remote: String,
114        /// SSH authentication overrides.
115        #[command(flatten)]
116        auth: SshAuthArgs,
117        /// Timeout override in milliseconds.
118        #[arg(long, value_name = "MS")]
119        timeout: Option<u64>,
120        /// JSON output (from global `--json`).
121        #[arg(from_global)]
122        json: bool,
123    },
124
125    /// Removes a remote file.
126    Rm {
127        /// VPS name.
128        vps_name: String,
129        /// Remote file path.
130        remote: String,
131        /// SSH authentication overrides.
132        #[command(flatten)]
133        auth: SshAuthArgs,
134        /// Timeout override in milliseconds.
135        #[arg(long, value_name = "MS")]
136        timeout: Option<u64>,
137        /// JSON output (from global `--json`).
138        #[arg(from_global)]
139        json: bool,
140    },
141
142    /// Shows metadata for a remote path.
143    Stat {
144        /// VPS name.
145        vps_name: String,
146        /// Remote path.
147        remote: String,
148        /// SSH authentication overrides.
149        #[command(flatten)]
150        auth: SshAuthArgs,
151        /// Timeout override in milliseconds.
152        #[arg(long, value_name = "MS")]
153        timeout: Option<u64>,
154        /// JSON output (from global `--json`).
155        #[arg(from_global)]
156        json: bool,
157    },
158
159    /// Renames a remote path.
160    Rename {
161        /// VPS name.
162        vps_name: String,
163        /// Current remote path.
164        from: String,
165        /// New remote path.
166        to: String,
167        /// SSH authentication overrides.
168        #[command(flatten)]
169        auth: SshAuthArgs,
170        /// Timeout override in milliseconds.
171        #[arg(long, value_name = "MS")]
172        timeout: Option<u64>,
173        /// JSON output (from global `--json`).
174        #[arg(from_global)]
175        json: bool,
176    },
177}