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