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
use clap::{App, Arg, SubCommand};
pub fn build_cli<'a>(app: &str, home: &'a str, version: &'a str) -> App<'a, 'a> {
App::new(app)
.about("S3 Client and Benchmarking Utility that can access AWS S3, Ceph or any third party S3 enable environment.")
.author("Chris Jones")
.version(version)
.after_help("For more information about a specific command, try `s3lsio <command> --help`\nSource code for s3lsio available at: https://github.com/lambdastackio/s3lsio")
.arg(Arg::with_name("generate-bash-completions")
.short("g")
.long("generate-bash-completions")
.help("Outputs bash completions"))
.arg(Arg::with_name("config")
.short("c")
.long("config")
.value_name("FILE")
.default_value(home)
.help("Sets a custom config file.")
.takes_value(true))
.arg(Arg::with_name("endpoint")
.short("e")
.long("endpoint")
.value_name("URL:<port>")
.help("Sets a custom endpoint URL:<port> (port is optional). Default is AWS default endpoints based on Region")
.takes_value(true))
.arg(Arg::with_name("bucket_virtual_host")
.short("i")
.long("bucket_virtual_host")
.value_name("true or false")
.help("Overrides the default of TRUE for virtual buckets. Useful for non AWS environments")
.default_value("true")
.takes_value(true))
.arg(Arg::with_name("output-color")
.short("l")
.long("output-color")
.default_value("green")
.value_name("green or red or blue or yellow or white or normal")
.help("Specifies the output color.")
.takes_value(true))
.arg(Arg::with_name("output-format")
.short("f")
.long("output-format")
.default_value("pretty-json")
.value_name("pretty-json or json or plain or serialize")
.help("Specifies the output to stdout (and disk in some cases). Options are json, none, noneall, pretty-json, plain, serialize")
.takes_value(true))
.arg(Arg::with_name("output-bench-format")
.short("o")
.long("output-bench-format")
.default_value("pretty-json")
.value_name("pretty-json or json or plain or serialize")
.help("Specifies the output to stdout (and disk in some cases). Options are json, none, noneall, pretty-json, plain, serialize")
.takes_value(true))
.arg(Arg::with_name("proxy")
.short("p")
.long("proxy")
.value_name("URL:<port>")
.help("Sets a custom proxy URL:<port>. Default is to use http(s)_proxy and no_proxy")
.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("Sets S3 Region.")
.takes_value(true))
.arg(Arg::with_name("signature")
.short("s")
.long("signature")
.value_name("V2 or V4")
.default_value("V4")
.help("Sets an API Signature version.")
.takes_value(true))
.arg(Arg::with_name("time")
.short("t")
.long("time")
.help("Track time duration of operation(s)"))
.arg(Arg::with_name("bench")
.short("b")
.long("bench")
.value_name("Format: N:N:N:N:A (N - Number, A - Alpha)")
.help("Benchmarking command: AAA:BBB:CCC:DDD:E AAA - Duration in seconds, BBB - Iterations (must be 0 if using duration), CCC - Virtual Users (threads), DDD - Hosts (only 1 for now), E - Summary or Detail (must be S or D). MUST set `-f noneall` when using this option.")
.takes_value(true))
.arg(Arg::with_name("yes")
.short("y")
.long("yes")
.help("Answer yes automatically"))
.subcommand(SubCommand::with_name("abort")
.about("Abort multipart upload: s3lsio abort <upload_id> s3://<bucket>/<object>")
.arg_from_usage("[upload_id] 'Multipart Upload ID'")
.arg_from_usage("[bucket] 'Bucket name'"))
.subcommand(SubCommand::with_name("acl")
.about("Get Bucket ACLs: s3lsio acl s3://<bucket>")
.arg_from_usage("[bucket] 'Bucket name'"))
.subcommand(SubCommand::with_name("head")
.about("Head Bucket or Object: s3lsio head s3://<bucket> or s3lsio head s3://<bucket>/<object>")
.arg_from_usage("[bucket] 'Bucket name'"))
.subcommand(SubCommand::with_name("ls")
.about("List Buckets or Objects in bucket with optional version tag: s3lsio ls OR s3lsio ls s3://<bucket>/<prefix> <option>")
.arg_from_usage("[bucket] 'Bucket name'")
.arg_from_usage("[option] 'ver or multi'")
.arg_from_usage("[upload_id] 'multipart upload ID option'"))
.subcommand(SubCommand::with_name("mb")
.about("Make Bucket: s3lsio mb s3://<bucket>")
.arg_from_usage("[bucket] 'Bucket name'"))
.subcommand(SubCommand::with_name("rb")
.about("Remove Bucket: s3lsio rb s3://<bucket>")
.arg_from_usage("[bucket] 'Bucket name'"))
.subcommand(SubCommand::with_name("rm")
.about("Remove Object and/or Object version: s3lsio rm s3://<bucket>/<object> <version>")
.arg_from_usage("[bucket] 'Bucket name'")
.arg_from_usage("[version] 'Version'"))
.subcommand(SubCommand::with_name("get")
.about("Get Object (use `cp`): s3lsio get s3://<bucket>/<object> <path>")
.arg_from_usage("[bucket] 'Bucket name'")
.arg_from_usage("[path] 'Path'"))
.subcommand(SubCommand::with_name("gen")
.about("Gen files: s3lsio 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("cp")
.about("Copy Object: s3lsio cp s3://<bucket>/<object> <path> OR s3lsio cp <path> s3://<bucket>/<object> <size of parts>")
.arg_from_usage("[bucket] 'Bucket name'")
.arg_from_usage("[path] 'Path'")
.arg_from_usage("[size] 'Size of parts'"))
.subcommand(SubCommand::with_name("put")
.about("Put Object (use `cp`) <size of parts> is optional: s3lsio put <path> s3://<bucket>/<object> <size of parts>")
.arg_from_usage("[path] 'Path (for benchmarking use `.`. Example: s3lsio put . s3://<bucket>/<object> <size of parts>)'")
.arg_from_usage("[bucket] 'Bucket name'")
.arg_from_usage("[size] 'Size of parts (for benchmarking this value is the size of the object to generate in bytes)'"))
.subcommand(SubCommand::with_name("range")
.about("Byte-Range request of Object: s3lsio range <offset> <len> s3://<bucket>/<object> <path>")
.arg_from_usage("[offset] 'Range begin offset'")
.arg_from_usage("[len] 'Range len'")
.arg_from_usage("[bucket] 'Bucket name'")
.arg_from_usage("[path] 'Path'"))
.subcommand(SubCommand::with_name("setacl")
.about("Set Bucket ACLs: s3lsio setacl <acl> s3://<bucket>")
.arg_from_usage("[acl] 'ACL - public-read, public-readwrite, private'")
.arg_from_usage("[bucket] 'Bucket name'"))
.subcommand(SubCommand::with_name("setver")
.about("Enables Bucket Versioning: s3lsio setver on|off s3://<bucket>")
.arg_from_usage("[ver] 'On or Off'")
.arg_from_usage("[bucket] 'Bucket name'"))
.subcommand(SubCommand::with_name("stats")
.about("Stats on Bucket or Object: s3lsio stats s3://<bucket> or s3lsio stats s3://<bucket>/<object>")
.arg_from_usage("[bucket] 'Bucket name or Bucket/Object name'"))
.subcommand(SubCommand::with_name("ver")
.about("Shows Bucket Versioning: s3lsio ver s3://<bucket>")
.arg_from_usage("[bucket] 'Bucket name'"))
}