Skip to content

Commit 6155cda

Browse files
committed
improve cli
1 parent 4e924c9 commit 6155cda

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "xcompress"
3-
version = "0.12.2"
3+
version = "0.12.3"
44
authors = ["Magic Len <[email protected]>"]
55
edition = "2021"
66
rust-version = "1.70"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ xcompress a foo.wav # Archive foo.wav to foo.rar
1313
xcompress a foo.wav /root/bar.txt # Archive foo.wav and /root/bar.txt to foo.rar
1414
xcompress a -o /tmp/out.7z foo.wav # Archive foo.wav to /tmp/out.7z
1515
xcompress a -b foo/bar # Archive foo/bar folder to bar.rar as small as possible
16+
xcompress a -f foo/bar -r 5 # Archive foo/bar folder to bar.rar as fast as possible and add 5% recovery record
1617
xcompress a -p password foo.wav # Archive foo.wav to foo.rar with a password
1718
xcompress x foo.rar # Extract foo.rar into current working directory
1819
xcompress x foo.tar.gz /tmp/out_folder # Extract foo.tar.gz into /tmp/out_folder
@@ -28,7 +29,7 @@ Commands:
2829
Options:
2930
-q, --quiet Make programs not print anything on the screen
3031
-s, --single-thread Use only one thread
31-
-p, --password <PASSWORD> Set password for your archive file. (Only supports 7Z, ZIP and RAR) Set an empty string to read a password from stdin
32+
-p, --password [<PASSWORD>] Set password for your archive file. (Only supports 7Z, ZIP and RAR) Set an empty string to read a password from stdin
3233
--compress-path <COMPRESS_PATH> Specify the path of your compress executable binary file [default: compress]
3334
--zip-path <ZIP_PATH> Specify the path of your zip executable binary file [default: zip]
3435
--unzip-path <UNZIP_PATH> Specify the path of your unzip executable binary file [default: unzip]
@@ -47,7 +48,7 @@ Options:
4748
--pxz-path <PXZ_PATH> Specify the path of your pxz executable binary file [default: pxz]
4849
--lzma-path <LZMA_PATH> Specify the path of your lzma executable binary file [default: lzma]
4950
--unlzma-path <UNLZMA_PATH> Specify the path of your unlzma executable binary file [default: unlzma]
50-
--7Z_PATH <P7Z_PATH> Specify the path of your 7z executable binary file [default: 7z]
51+
--7z-path <7z-path> Specify the path of your 7z executable binary file [default: 7z]
5152
--tar-path <TAR_PATH> Specify the path of your tar executable binary file [default: tar]
5253
--rar-path <RAR_PATH> Specify the path of your rar executable binary file [default: rar]
5354
--unrar-path <UNRAR_PATH> Specify the path of your unrar executable binary file [default: unrar]

src/cli.rs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,150 +88,176 @@ pub struct ExecutablePaths {
8888
#[arg(long)]
8989
#[arg(global = true)]
9090
#[arg(default_value = DEFAULT_COMPRESS_PATH)]
91+
#[arg(value_hint = clap::ValueHint::CommandName)]
9192
#[arg(help = "Specify the path of your compress executable binary file")]
9293
pub compress_path: String,
9394

9495
#[arg(long)]
9596
#[arg(global = true)]
9697
#[arg(default_value = DEFAULT_ZIP_PATH)]
98+
#[arg(value_hint = clap::ValueHint::CommandName)]
9799
#[arg(help = "Specify the path of your zip executable binary file")]
98100
pub zip_path: String,
99101

100102
#[arg(long)]
101103
#[arg(global = true)]
102104
#[arg(default_value = DEFAULT_UNZIP_PATH)]
105+
#[arg(value_hint = clap::ValueHint::CommandName)]
103106
#[arg(help = "Specify the path of your unzip executable binary file")]
104107
pub unzip_path: String,
105108

106109
#[arg(long)]
107110
#[arg(global = true)]
108111
#[arg(default_value = DEFAULT_GZIP_PATH)]
112+
#[arg(value_hint = clap::ValueHint::CommandName)]
109113
#[arg(help = "Specify the path of your gzip executable binary file")]
110114
pub gzip_path: String,
111115

112116
#[arg(long)]
113117
#[arg(global = true)]
114118
#[arg(default_value = DEFAULT_GUNZIP_PATH)]
119+
#[arg(value_hint = clap::ValueHint::CommandName)]
115120
#[arg(help = "Specify the path of your gunzip executable binary file")]
116121
pub gnuzip_path: String,
117122

118123
#[arg(long)]
119124
#[arg(global = true)]
120125
#[arg(default_value = DEFAULT_PIGZ_PATH)]
126+
#[arg(value_hint = clap::ValueHint::CommandName)]
121127
#[arg(help = "Specify the path of your pigz executable binary file")]
122128
pub pigz_path: String,
123129

124130
#[arg(long)]
125131
#[arg(global = true)]
126132
#[arg(default_value = DEFAULT_BZIP2_PATH)]
133+
#[arg(value_hint = clap::ValueHint::CommandName)]
127134
#[arg(help = "Specify the path of your bzip2 executable binary file")]
128135
pub bzip2_path: String,
129136

130137
#[arg(long)]
131138
#[arg(global = true)]
132139
#[arg(default_value = DEFAULT_BUNZIP2_PATH)]
140+
#[arg(value_hint = clap::ValueHint::CommandName)]
133141
#[arg(help = "Specify the path of your bunzip2 executable binary file")]
134142
pub bunzip2_path: String,
135143

136144
#[arg(long)]
137145
#[arg(global = true)]
138146
#[arg(default_value = DEFAULT_LBZIP2_PATH)]
147+
#[arg(value_hint = clap::ValueHint::CommandName)]
139148
#[arg(help = "Specify the path of your lbzip2 executable binary file")]
140149
pub lbzip2_path: String,
141150

142151
#[arg(long)]
143152
#[arg(global = true)]
144153
#[arg(default_value = DEFAULT_PBZIP2_PATH)]
154+
#[arg(value_hint = clap::ValueHint::CommandName)]
145155
#[arg(help = "Specify the path of your pbzip2 executable binary file")]
146156
pub pbzip2_path: String,
147157

148158
#[arg(long)]
149159
#[arg(global = true)]
150160
#[arg(default_value = DEFAULT_LZIP_PATH)]
161+
#[arg(value_hint = clap::ValueHint::CommandName)]
151162
#[arg(help = "Specify the path of your lzip executable binary file")]
152163
pub lzip_path: String,
153164

154165
#[arg(long)]
155166
#[arg(global = true)]
156167
#[arg(default_value = DEFAULT_LUNZIP_PATH)]
168+
#[arg(value_hint = clap::ValueHint::CommandName)]
157169
#[arg(help = "Specify the path of your lunzip executable binary file")]
158170
pub lunzip_path: String,
159171

160172
#[arg(long)]
161173
#[arg(global = true)]
162174
#[arg(default_value = DEFAULT_PLZIP_PATH)]
175+
#[arg(value_hint = clap::ValueHint::CommandName)]
163176
#[arg(help = "Specify the path of your plzip executable binary file")]
164177
pub plzip_path: String,
165178

166179
#[arg(long)]
167180
#[arg(global = true)]
168181
#[arg(default_value = DEFAULT_XZ_PATH)]
182+
#[arg(value_hint = clap::ValueHint::CommandName)]
169183
#[arg(help = "Specify the path of your xz executable binary file")]
170184
pub xz_path: String,
171185

172186
#[arg(long)]
173187
#[arg(global = true)]
174188
#[arg(default_value = DEFAULT_UNXZ_PATH)]
189+
#[arg(value_hint = clap::ValueHint::CommandName)]
175190
#[arg(help = "Specify the path of your unxz executable binary file")]
176191
pub unxz_path: String,
177192

178193
#[arg(long)]
179194
#[arg(global = true)]
180195
#[arg(default_value = DEFAULT_PXZ_PATH)]
196+
#[arg(value_hint = clap::ValueHint::CommandName)]
181197
#[arg(help = "Specify the path of your pxz executable binary file")]
182198
pub pxz_path: String,
183199

184200
#[arg(long)]
185201
#[arg(global = true)]
186202
#[arg(default_value = DEFAULT_LZMA_PATH)]
203+
#[arg(value_hint = clap::ValueHint::CommandName)]
187204
#[arg(help = "Specify the path of your lzma executable binary file")]
188205
pub lzma_path: String,
189206

190207
#[arg(long)]
191208
#[arg(global = true)]
192209
#[arg(default_value = DEFAULT_UNLZMA_PATH)]
210+
#[arg(value_hint = clap::ValueHint::CommandName)]
193211
#[arg(help = "Specify the path of your unlzma executable binary file")]
194212
pub unlzma_path: String,
195213

196-
#[arg(long = "7Z_PATH")]
214+
#[arg(name = "7z-path")]
215+
#[arg(long)]
197216
#[arg(global = true)]
198217
#[arg(default_value = DEFAULT_7Z_PATH)]
218+
#[arg(value_hint = clap::ValueHint::CommandName)]
199219
#[arg(help = "Specify the path of your 7z executable binary file")]
200220
pub p7z_path: String,
201221

202222
#[arg(long)]
203223
#[arg(global = true)]
204224
#[arg(default_value = DEFAULT_TAR_PATH)]
225+
#[arg(value_hint = clap::ValueHint::CommandName)]
205226
#[arg(help = "Specify the path of your tar executable binary file")]
206227
pub tar_path: String,
207228

208229
#[arg(long)]
209230
#[arg(global = true)]
210231
#[arg(default_value = DEFAULT_RAR_PATH)]
232+
#[arg(value_hint = clap::ValueHint::CommandName)]
211233
#[arg(help = "Specify the path of your rar executable binary file")]
212234
pub rar_path: String,
213235

214236
#[arg(long)]
215237
#[arg(global = true)]
216238
#[arg(default_value = DEFAULT_UNRAR_PATH)]
239+
#[arg(value_hint = clap::ValueHint::CommandName)]
217240
#[arg(help = "Specify the path of your unrar executable binary file")]
218241
pub unrar_path: String,
219242

220243
#[arg(long)]
221244
#[arg(global = true)]
222245
#[arg(default_value = DEFAULT_ZSTD_PATH)]
246+
#[arg(value_hint = clap::ValueHint::CommandName)]
223247
#[arg(help = "Specify the path of your zstd executable binary file")]
224248
pub zstd_path: String,
225249

226250
#[arg(long)]
227251
#[arg(global = true)]
228252
#[arg(default_value = DEFAULT_UNZSTD_PATH)]
253+
#[arg(value_hint = clap::ValueHint::CommandName)]
229254
#[arg(help = "Specify the path of your unzstd executable binary file")]
230255
pub unzstd_path: String,
231256

232257
#[arg(long)]
233258
#[arg(global = true)]
234259
#[arg(default_value = DEFAULT_PZSTD_PATH)]
260+
#[arg(value_hint = clap::ValueHint::CommandName)]
235261
#[arg(help = "Specify the path of your pzstd executable binary file")]
236262
pub pzstd_path: String,
237263
}
@@ -241,14 +267,17 @@ pub enum CLICommands {
241267
#[command(about = "Extract files with full path")]
242268
#[command(after_help = AFTER_HELP)]
243269
X {
270+
#[arg(value_hint = clap::ValueHint::FilePath)]
244271
#[arg(
245272
help = "Assign the source of your original files. It should be at least one file path"
246273
)]
247274
input_path: PathBuf,
248-
#[arg(help = "Assign a destination of your extracted files. It should be a directory path")]
275+
#[arg(value_hint = clap::ValueHint::DirPath)]
249276
#[arg(conflicts_with = "output")]
277+
#[arg(help = "Assign a destination of your extracted files. It should be a directory path")]
250278
output_path: Option<PathBuf>,
251279
#[arg(short, long)]
280+
#[arg(value_hint = clap::ValueHint::DirPath)]
252281
#[arg(conflicts_with = "output_path")]
253282
#[arg(help = "Assign a destination of your extracted files. It should be a directory path")]
254283
output: Option<PathBuf>,
@@ -259,11 +288,13 @@ pub enum CLICommands {
259288
#[command(after_help = AFTER_HELP)]
260289
A {
261290
#[arg(required = true)]
291+
#[arg(value_hint = clap::ValueHint::AnyPath)]
262292
#[arg(
263293
help = "Assign the source of your original files. It should be at least one file path"
264294
)]
265295
input_paths: Vec<PathBuf>,
266296
#[arg(short, long)]
297+
#[arg(value_hint = clap::ValueHint::FilePath)]
267298
#[arg(help = "Assign a destination of your extracted files. It should be a file path. \
268299
Specify the file extension name in order to determine which archive \
269300
format you want to use. [default archive format: RAR]")]

0 commit comments

Comments
 (0)