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        /// Paths: `VPS LOCAL REMOTE`, multi-file `VPS LOCAL... REMOTE_DIR`, or fleet forms with `--all`/`--hosts`.
21        #[arg(required = true, num_args = 2.., value_names = ["VPS", "LOCAL", "REMOTE"])]
22        target: Vec<String>,
23        /// Recursively upload a local directory tree (no symlink follow).
24        #[arg(short = 'r', long, action = ArgAction::SetTrue)]
25        recursive: bool,
26        /// SSH authentication overrides.
27        #[command(flatten)]
28        auth: SshAuthArgs,
29        /// Timeout override in milliseconds (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 or tree to the local host via SFTP.
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`, multi-file forms, or fleet forms with `--all`/`--hosts`.
46        #[arg(required = true, num_args = 2.., value_names = ["VPS", "REMOTE", "LOCAL"])]
47        target: Vec<String>,
48        /// Recursively download a remote directory tree (no symlink follow).
49        #[arg(short = 'r', long, action = ArgAction::SetTrue)]
50        recursive: bool,
51        /// SSH authentication overrides.
52        #[command(flatten)]
53        auth: SshAuthArgs,
54        /// Timeout override in milliseconds (connect+transfer).
55        #[arg(long, value_name = "MS")]
56        timeout: Option<u64>,
57        /// JSON output (from global `--json`).
58        #[arg(from_global)]
59        json: bool,
60    },
61
62    /// Lists a remote directory.
63    Ls {
64        /// VPS name.
65        vps_name: String,
66        /// Remote directory path.
67        remote: String,
68        /// SSH authentication overrides.
69        #[command(flatten)]
70        auth: SshAuthArgs,
71        /// Timeout override in milliseconds.
72        #[arg(long, value_name = "MS")]
73        timeout: Option<u64>,
74        /// JSON output (from global `--json`).
75        #[arg(from_global)]
76        json: bool,
77    },
78
79    /// Creates a remote directory.
80    Mkdir {
81        /// VPS name.
82        vps_name: String,
83        /// Remote directory path.
84        remote: String,
85        /// SSH authentication overrides.
86        #[command(flatten)]
87        auth: SshAuthArgs,
88        /// Timeout override in milliseconds.
89        #[arg(long, value_name = "MS")]
90        timeout: Option<u64>,
91        /// JSON output (from global `--json`).
92        #[arg(from_global)]
93        json: bool,
94    },
95
96    /// Removes an empty remote directory.
97    Rmdir {
98        /// VPS name.
99        vps_name: String,
100        /// Remote directory path.
101        remote: String,
102        /// SSH authentication overrides.
103        #[command(flatten)]
104        auth: SshAuthArgs,
105        /// Timeout override in milliseconds.
106        #[arg(long, value_name = "MS")]
107        timeout: Option<u64>,
108        /// JSON output (from global `--json`).
109        #[arg(from_global)]
110        json: bool,
111    },
112
113    /// Removes a remote file.
114    Rm {
115        /// VPS name.
116        vps_name: String,
117        /// Remote file path.
118        remote: String,
119        /// SSH authentication overrides.
120        #[command(flatten)]
121        auth: SshAuthArgs,
122        /// Timeout override in milliseconds.
123        #[arg(long, value_name = "MS")]
124        timeout: Option<u64>,
125        /// JSON output (from global `--json`).
126        #[arg(from_global)]
127        json: bool,
128    },
129
130    /// Shows metadata for a remote path.
131    Stat {
132        /// VPS name.
133        vps_name: String,
134        /// Remote path.
135        remote: String,
136        /// SSH authentication overrides.
137        #[command(flatten)]
138        auth: SshAuthArgs,
139        /// Timeout override in milliseconds.
140        #[arg(long, value_name = "MS")]
141        timeout: Option<u64>,
142        /// JSON output (from global `--json`).
143        #[arg(from_global)]
144        json: bool,
145    },
146
147    /// Renames a remote path.
148    Rename {
149        /// VPS name.
150        vps_name: String,
151        /// Current remote path.
152        from: String,
153        /// New remote path.
154        to: String,
155        /// SSH authentication overrides.
156        #[command(flatten)]
157        auth: SshAuthArgs,
158        /// Timeout override in milliseconds.
159        #[arg(long, value_name = "MS")]
160        timeout: Option<u64>,
161        /// JSON output (from global `--json`).
162        #[arg(from_global)]
163        json: bool,
164    },
165}