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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
//! Contains the code for the CLI command generation: arguments, flags, etc.
use clap::{command, Arg, ArgAction, Command};
pub fn get_command() -> Command {
command!()
/* BASE COMMAND */
.arg(Arg::new("DEBUG")
.short('d')
.long("debug")
.action(ArgAction::SetTrue)
.help("Turns on extensive debug output information")
)
.arg(Arg::new("VERBOSE")
.short('v')
.long("verbose")
.help("Use verbose output (extra information)")
.action(ArgAction::SetTrue)
.conflicts_with("QUIET")
)
.arg(Arg::new("QUIET")
.short('q')
.long("quiet")
.help("Do not print any log messages")
.action(ArgAction::SetTrue)
.conflicts_with("VERBOSE")
)
/* BOX SUBCOMMAND */
.subcommand(Command::new("box")
.about("Encrypt specified files into a special file type")
.arg(Arg::new("PATH")
.help("Specify the path(s) to a file or directory for encryption. A file path encrypts the file and a directory path encrypts all files within")
.default_value(".")
.action(ArgAction::Append)
)
.arg(Arg::new("PASSWORD")
.short('p')
.long("password")
.help("Specify the password used for authentication")
.action(ArgAction::Set)
)
.arg(Arg::new("RECURSIVE")
.short('R')
.long("recursive")
.help("Recursively encrypt directory")
.action(ArgAction::SetTrue)
)
.arg(Arg::new("KEEP_NAME")
.short('k')
.long("keep-name")
.help("Keep original file name for the encrypted file")
.action(ArgAction::SetTrue)
.conflicts_with("OUTPUT")
)
.arg(Arg::new("OUTPUT")
.short('o')
.long("output")
.help("Specify a path for the output file. In case of multiple input paths, output paths will be specified in order of the input")
.action(ArgAction::Append)
.conflicts_with("KEEP_NAME")
)
.arg(Arg::new("SHOW_FULL_PATH")
.short('f')
.long("full")
.help("Output the full relative path to the encrypted file")
.action(ArgAction::SetTrue)
)
// .arg(Arg::new("overwrite") // TODO
// .short('w')
// .long("overwrite")
// .help("Automatically overwrite existing files without prompting the user")
// .action(ArgAction::SetTrue)
// )
// .arg(Arg::new("compression") // TODO
// .short('z')
// .long("compression")
// .help("Compresses the file(s) before encryption")
// .action(ArgAction::Set)
// .default_value("none")
// )
// .arg(Arg::new("exclude") // TODO
// .short('e')
// .long("exclude")
// .help("Exclude specific file patterns from being encrypted")
// .action(ArgAction::Set)
// )
// .arg(Arg::new("preserve-timestamp") // TODO
// .long("preserve-timestamp")
// .help("Retains the original file's timestamp when creating the encrypted file")
// .action(ArgAction::SetTrue)
// )
)
/* UNBOX SUBCOMMAND */
.subcommand(Command::new("unbox")
.about("Decrypt specified files from a special file type")
.arg(Arg::new("PATH")
.help("Specify the path(s) to a file or directory for encryption. A file path encrypts the file and a directory path encrypts all files within")
.default_value(".")
.action(ArgAction::Append)
)
.arg(Arg::new("PASSWORD")
.short('p')
.long("password")
.help("Specify the password used for authentication")
.action(ArgAction::Set)
)
.arg(Arg::new("RECURSIVE")
.short('R')
.long("recursive")
.help("Recursively decrypt directory")
.action(ArgAction::SetTrue)
)
.arg(Arg::new("OUTPUT")
.short('o')
.long("output")
.help("Specify a path for the output file. In case of multiple input paths, output paths will be specified in order of the input")
.action(ArgAction::Append)
)
.arg(Arg::new("SHOW_FULL_PATH")
.short('f')
.long("full")
.help("Output the full relative path to the decrypted file")
.action(ArgAction::SetTrue)
)
// .arg(Arg::new("overwrite") // TODO
// .short('w')
// .long("overwrite")
// .help("Automatically overwrite existing files without prompting the user")
// .action(ArgAction::SetTrue)
// )
// .arg(Arg::new("check-integrity") // TODO
// .short('i')
// .long("check-integrity")
// .help("Validates the integrity of the decrypted file by comparing it with an original checksum (if available)")
// .action(ArgAction::SetTrue)
// )
// .arg(Arg::new("preserve-attributes") // TODO
// .long("preserve-attributes")
// .help("Preserves original file attributes (e.g., permissions, timestamps) when decrypting")
// .action(ArgAction::SetTrue)
// )
)
.subcommand(Command::new("information")
.about("Parse and get original file information from a \".box\" file")
.alias("info")
.arg(Arg::new("PATH")
.help("Specify the the target encrypted \".box\" file")
.required(true)
.action(ArgAction::Set)
)
.arg(Arg::new("SHOW_UNKNOWN")
.short('u')
.long("unknown")
.help("Show the unknown metadata")
.action(ArgAction::SetTrue)
)
)
/* PROFILE SUBCOMMAND */
.subcommand(Command::new("profile")
.about("Control custom profiles")
/* CREATE PROFILE SUBCOMMAND */
.subcommand(Command::new("new")
.about("Create a new profile")
.alias("create")
.arg(Arg::new("NAME")
.help("A unique name for the profile")
.required(true)
)
.arg(Arg::new("PASSWORD")
.short('p')
.long("password")
.help("Specify the password used for authentication")
.action(ArgAction::Set)
)
)
/* DELETE PROFILE SUBCOMMAND */
.subcommand(Command::new("delete")
.about("Delete a specified profile")
.alias("remove")
.arg(Arg::new("NAME")
.help("Name of the profile to delete")
.required(true)
)
.arg(Arg::new("PASSWORD")
.short('p')
.long("password")
.help("Specify the password used for authentication")
.action(ArgAction::Set)
)
)
/* SELECT PROFILE SUBCOMMAND */
.subcommand(Command::new("set")
.about("Select a profile to use")
.alias("select")
.arg(Arg::new("NAME")
.help("Name of the profile to switch to")
.required(true)
)
.arg(Arg::new("PASSWORD")
.short('p')
.long("password")
.help("Specify the password used for authentication")
.action(ArgAction::Set)
)
)
/* GET PROFILE SUBCOMMAND */
.subcommand(Command::new("get")
.about("Get current profile's name")
.alias("current")
)
/* LIST PROFILE SUBCOMMAND */
.subcommand(Command::new("list")
.about("List all available profiles (names)")
)
)
/* KEY SUBCOMMAND */
.subcommand(Command::new("key")
.about("Control profile\'s encryption key")
/* GENERATE KEY SUBCOMMAND */
.subcommand(Command::new("new")
.about("Generate a new encryption key for the current profile")
.alias("generate")
.arg(Arg::new("PASSWORD")
.short('p')
.long("password")
.help("Specify the password used for authentication")
.action(ArgAction::Set)
)
)
/* GET KEY SUBCOMMAND */
.subcommand(Command::new("get")
.about("Get current profile\'s encryption key")
.arg(Arg::new("PASSWORD")
.short('p')
.long("password")
.help("Specify the password used for authentication")
.action(ArgAction::Set)
)
.arg(Arg::new("AS_BYTE_ARRAY")
.help("Output key as an array of bytes")
.short('b')
.long("byte-array")
.action(ArgAction::SetTrue)
)
)
/* SET KEY SUBCOMMAND */
.subcommand(Command::new("set")
.about("Set a new key for the current profile")
.arg(Arg::new("KEY")
.help("A 32-byte encryption key represented by hex values (e.g.: DA495EFCF25904AC2FF438BE380FF660E150E65B03AC543398C43AD4FC617962)")
.required(true)
)
.arg(Arg::new("PASSWORD")
.short('p')
.long("password")
.help("Specify the password used for authentication")
.action(ArgAction::Set)
)
)
)
}