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
use clap::{App, Arg, SubCommand};
static DEFAULT_USER_AGENT: &'static str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
pub fn build_cli<'a>(app: &str, config_dir: &'a str, version: &'a str) -> App<'a, 'a> {
App::new(app)
.about("LsioHTTPS Server")
.author("Chris Jones")
.version(version)
.after_help("For more information about a specific command, try `lsiohttps <command> --help`\nSource code for lsiohttps available at: https://github.com/lambdastackio/lsiohttps")
.arg(Arg::with_name("bench")
.short("b")
.long("bench")
.value_name("Format: N:N:N:N:N:A (N - Number, A - Alpha)")
.help("Benchmarking command: AAA:BBB:CCC:DDD:EEE:F AAA - Duration in seconds, BBB - Iterations (must be 0 if using duration), CCC - Virtual Users (threads), DDD - Hosts (only 1 for now), EEE - Ramp up time (0 - Thundering Heard, anythig else spread out), F - Summary or Detail (must be S or D). MUST set `-f noneall` when using this option.")
.takes_value(true))
.arg(Arg::with_name("config")
.short("c")
.long("config")
.value_name("FILE")
.default_value(config_dir)
.help("Sets a custom config file.")
.takes_value(true))
.arg(Arg::with_name("daemonize")
.short("d")
.long("daemonize")
.help("Overrides the default of TRUE for daemonization. Useful for server in foreground"))
.arg(Arg::with_name("endpoint")
.short("e")
.long("endpoint")
.value_name("URL:<port>")
.help("Outbound - Sets a custom endpoint URL:<port> (port is optional). Default is AWS default endpoints based on Region")
.takes_value(true))
.arg(Arg::with_name("base-path")
.short("f")
.long("base-path")
.value_name("public")
.default_value("public")
.help("Location of the base path of where the site files are located. Default is 'public' (relative to where app is located) but could be /var/www/html")
.takes_value(true))
.arg(Arg::with_name("generate-bash-completions")
.short("g")
.long("generate-bash-completions")
.help("Outputs bash completions"))
.arg(Arg::with_name("bucket-virtual-host")
.short("h")
.long("bucket-virtual-host")
.help("Overrides the default of TRUE for virtual buckets. Useful for non AWS environments"))
.arg(Arg::with_name("ip")
.short("i")
.long("ip")
.value_name("IP Address")
.default_value("127.0.0.1")
.help("Sets the IP Address")
.takes_value(true))
.arg(Arg::with_name("pid")
.short("j")
.long("pid")
.value_name("PID file location")
.default_value("/tmp")
.help("Overrides the default PID file location")
.takes_value(true))
.arg(Arg::with_name("run-as-user")
.short("k")
.long("run-as-user")
.value_name("User to run as")
.default_value("nobody")
.help("Overrides the default user of 'nobody' to run server as")
.takes_value(true))
.arg(Arg::with_name("log")
.short("l")
.long("log")
.value_name("Log file location")
.default_value("/tmp")
.help("Overrides the default log file location")
.takes_value(true))
.arg(Arg::with_name("run-in-group")
.short("m")
.long("run-in-group")
.value_name("Belongs to group to run")
.default_value("daemon")
.help("Overrides the default group of 'daemon' to run server in")
.takes_value(true))
.arg(Arg::with_name("port")
.short("p")
.long("port")
.value_name("Port of IP Address")
.default_value("8000")
.help("Sets the port of the IP Address")
.takes_value(true))
.arg(Arg::with_name("quiet")
.short("q")
.long("quiet")
.help("No output is produced"))
.arg(Arg::with_name("region")
.short("r")
.long("region")
.value_name("Region")
.default_value("UsEast1")
.help("Outbound - Sets S3 Region.")
.takes_value(true))
.arg(Arg::with_name("signature")
.short("s")
.long("signature")
.value_name("V2 or V4")
.default_value("V4")
.help("Outbound - Sets an API Signature version for S3 calls.")
.takes_value(true))
.arg(Arg::with_name("time")
.short("t")
.long("time")
.help("Track time duration of operation(s)"))
.arg(Arg::with_name("user-agent")
.short("u")
.long("user-agent")
.value_name("User-agent")
.default_value(DEFAULT_USER_AGENT)
.help("Outbound - Sets the user-agent string.")
.takes_value(true))
.arg(Arg::with_name("proxy")
.short("x")
.long("proxy")
.value_name("URL:<port>")
.help("Outbound - Sets a custom proxy URL:<port>. Default is to use http(s)_proxy and no_proxy")
.takes_value(true))
.subcommand(SubCommand::with_name("bench")
.about("Benchmarking: lsiohttps bench <command> <options>")
.subcommand(SubCommand::with_name("gen")
.about("Benchmarking Gen files (only if desired): s3lsio bench gen <path> s3://<bucket>/<object> <size>. Generates synthetic files of a given size.")
.arg_from_usage("[bucket] 'Bucket name'")
.arg_from_usage("[path] 'Path'")
.arg_from_usage("[size] 'Size of file'"))
.subcommand(SubCommand::with_name("get")
.about("Benchmarking GET Object: s3lsio bench get s3://<bucket>/<object>")
.arg_from_usage("[bucket] 'Bucket name/object name'"))
.subcommand(SubCommand::with_name("put")
.about("Benchmarking PUT Object: s3lsio bench put s3://<bucket>/<object> <size> <size-of-parts>")
.arg_from_usage("[bucket] 'Bucket name'")
.arg_from_usage("[size] 'Size of object in bytes'")
.arg_from_usage("[size_of_parts] 'Size of each part for multipart upload'"))
.subcommand(SubCommand::with_name("range")
.about("Benchmarking Byte-Range request of Object: s3lsio bench range <offset> <len> s3://<bucket>/<object>")
.arg_from_usage("[offset] 'Range begin offset'")
.arg_from_usage("[len] 'Range len'")
.arg_from_usage("[bucket] 'Bucket name/object name'")))
.subcommand(SubCommand::with_name("admin")
.about("Admin Options: lsiohttps admin <command> <options>")
.subcommand(SubCommand::with_name("bucket")
.about("Admin Bucket Options: s3lsio admin bucket <command> s3://<bucket> <user> <stats> <fix> <check>")
.arg_from_usage("[command] 'Commands: delete - Delete, ls - List, stats - stats, link - Link, policy - Policy, unlink - Unlink, index - Index'")
.arg_from_usage("[bucket] 'Bucket name or Bucket/Object name'")
.arg_from_usage("[user] 'User ID (uid) (Not required on delete)'")
.arg_from_usage("[stats] '(Optional) - true or false. Default is false. Only used with stats command'")
.arg_from_usage("[fix] '(Optional) - true or false. Default is false. Only used with index command'")
.arg_from_usage("[check] '(Optional) - true or false. Default is false. Only used with index command'"))
.subcommand(SubCommand::with_name("quota")
.about("Admin Quota Options: s3lsio admin quota <user> <command> <action> <size> <count>")
.arg_from_usage("[user] 'User ID (uid)'")
.arg_from_usage("[command] 'Commands: bucket - Bucket, user - User'")
.arg_from_usage("[action] 'Action: get - Get, set - Set, enable - Enable quota, disable - Disable quota'")
.arg_from_usage("[size] 'Quota size - max size in KB (defaults to 0)'")
.arg_from_usage("[count] 'Quota object count - max number of objects (defaults to 0)'"))
.subcommand(SubCommand::with_name("cap")
.about("Admin Caps Admin User: s3lsio admin cap <user> <caps>")
.arg_from_usage("[user] 'User ID (uid)'")
.arg_from_usage("[caps] 'Admin Capability of user'"))
.subcommand(SubCommand::with_name("user")
.about("Admin User Options: s3lsio admin user <commands> [options]")
.subcommand(SubCommand::with_name("create")
.about("Admin Create User: s3lsio admin user create <user> <display_name> <email> <access_key> <secret_key> <caps>")
.arg_from_usage("[user] 'User ID (uid)'")
.arg_from_usage("[display_name] 'Display name - multi-word names should be inside of quotation marks'")
.arg_from_usage("[email] '(Optional) User email (optional)'")
.arg_from_usage("[access_key] '(Optional) Access Key ID'")
.arg_from_usage("[secret_key] '(Optional) Secret Key ID'")
.arg_from_usage("[suspended] '(Optional) Suspend user. Defaults to false'")
.arg_from_usage("[caps] '(Optional) Capability of user'"))
.subcommand(SubCommand::with_name("delete")
.about("Admin Delete User: s3lsio admin user delete <user> <purge_data>")
.arg_from_usage("[user] 'User ID (uid)'")
.arg_from_usage("[purge_data] '(Optional) Purge data. Defaults to false'"))
.subcommand(SubCommand::with_name("modify")
.about("Admin Modify User: s3lsio admin user modify <user> <purge_data>")
.arg_from_usage("[user] 'User ID (uid)'")
.arg_from_usage("[display_name] '(Optional) Display name - multi-word names should be inside of quotation marks'")
.arg_from_usage("[suspended] '(Optional) Suspend user. Defaults to false'")
.arg_from_usage("[email] '(Optional) User email'")
.arg_from_usage("[access_key] '(Optional) Access Key ID (optional)'")
.arg_from_usage("[secret_key] '(Optional) Secret Key ID (optional)'")
.arg_from_usage("[caps] '(Optional) Secret Key ID (optional)'")
.arg_from_usage("[max_buckets] '(Optional) Maximum number of buckets. Defaults to 1000'"))
.subcommand(SubCommand::with_name("get")
.about("Admin Get User: s3lsio admin user get <user>")
.arg_from_usage("[user] 'User ID (uid)'"))
.subcommand(SubCommand::with_name("ls")
.about("Admin List Users: s3lsio admin user ls")))
.subcommand(SubCommand::with_name("usage")
.about("Admin Usage Options: s3lsio admin usage ls <user> <start> <end> <show_entries> <show_summary>")
.subcommand(SubCommand::with_name("ls")
.arg_from_usage("[user] 'User ID (uid). If not supplied then the command applies to all users'")
.arg_from_usage("[start] 'Start DateTime [yyyy-mm-dd hh:mm:ss] (optional)'")
.arg_from_usage("[end] 'End DateTime [yyyy-mm-dd hh:mm:ss] (optional)'")
.arg_from_usage("[show_entries] 'Specifies whether data entries should be returned [true or false] (Default is false)'")
.arg_from_usage("[show_summary] 'Specifies whether data summary should be returned [true or false] (Default is false)'"))
.subcommand(SubCommand::with_name("trim")
.about("Admin Usage Options: s3lsio admin usage trim <user> <start> <end> <remove_all>")
.arg_from_usage("[user] 'User ID (uid). If not supplied then the command applies to all users'")
.arg_from_usage("[start] 'Start DateTime [yyyy-mm-dd hh:mm:ss] (optional)'")
.arg_from_usage("[end] 'End DateTime [yyyy-mm-dd hh:mm:ss] (optional)'")
.arg_from_usage("[remove_all] 'Remove all usage data [true or false] (optional except when no user is supplied)'")))
.subcommand(SubCommand::with_name("keys")
.about("Admin Keys Options: s3lsio admin keys <command> [options]")
.subcommand(SubCommand::with_name("create")
.about("Admin Keys Create: s3lsio admin keys create <user> <access_key> <secret_key> <generate_key>")
.arg_from_usage("[user] 'User ID (uid)'")
.arg_from_usage("[generate_key] '(Optional) Generate keys. Default is true'")
.arg_from_usage("[access_key] '(Optional) Access Key ID'")
.arg_from_usage("[secret_key] '(Optional) Secret Key ID'"))
.subcommand(SubCommand::with_name("delete")
.about("Admin Delete Keys: s3lsio admin keys delete <access_key> <user>")
.arg_from_usage("[access_key] 'Access Key ID'")
.arg_from_usage("[user] '(Optional) User ID (uid)'"))
.subcommand(SubCommand::with_name("gen")
.about("Admin Generate Keys (only): s3lsio admin keys gen <access_key> <secret_key>")
.arg_from_usage("[access_key] '(Optional) Access Key ID (default to true)'")
.arg_from_usage("[secret_key] '(Optional) Secret Key ID (default to true)'"))))
}