Skip to content

Commit 56309a4

Browse files
sinhaashishnitisht
authored andcommitted
mc command cleanup (minio#2783)
1 parent 2d69150 commit 56309a4

22 files changed

+321
-270
lines changed

CONFLICT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Besides `mc` is a single static binary and can reside inside your application an
66

77
Package managers are free to choose a different name if they like. One such solution [pointed out](https://github.com/minio/mc/issues/873#issuecomment-267583013) by one of our community members.
88

9-
```sh
9+
```
1010
mv ./mc ./mcli
1111
```

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Setup your mc Github Repository
22
Fork [mc upstream](https://github.com/minio/mc/fork) source repository to your own personal repository.
3-
```sh
3+
```
44
$ mkdir -p $GOPATH/src/github.com/minio
55
$ cd $GOPATH/src/github.com/minio
66
$ git clone https://github.com/$USER_ID/mc

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ docker run minio/mc:edge ls play
4343

4444
**Note:** Above examples run `mc` against MinIO [_play_ environment](#test-your-setup) by default. To run `mc` against other S3 compatible servers, start the container this way:
4545

46-
```sh
46+
```
4747
docker run -it --entrypoint=/bin/sh minio/mc
4848
```
4949

@@ -53,7 +53,7 @@ then use the [`mc config` command](#add-a-cloud-storage-service).
5353
### Homebrew
5454
Install mc packages using [Homebrew](http://brew.sh/)
5555

56-
```sh
56+
```
5757
brew install minio/stable/mc
5858
mc --help
5959
```
@@ -65,7 +65,7 @@ mc --help
6565
|GNU/Linux|64-bit Intel|https://dl.min.io/client/mc/release/linux-amd64/mc |
6666
||64-bit PPC|https://dl.min.io/client/mc/release/linux-ppc64le/mc |
6767

68-
```sh
68+
```
6969
wget https://dl.min.io/client/mc/release/linux-amd64/mc
7070
chmod +x mc
7171
./mc --help
@@ -77,7 +77,7 @@ chmod +x mc
7777
| ---------- | -------- |------|
7878
|Microsoft Windows|64-bit Intel|https://dl.min.io/client/mc/release/windows-amd64/mc.exe |
7979

80-
```sh
80+
```
8181
mc.exe --help
8282
```
8383

@@ -86,7 +86,7 @@ Source installation is intended only for developers and advanced users. `mc upda
8686

8787
If you do not have a working Golang environment, please follow [How to install Golang](https://docs.min.io/docs/how-to-install-golang).
8888

89-
```sh
89+
```
9090
go get -d github.com/minio/mc
9191
cd ${GOPATH}/src/github.com/minio/mc
9292
make
@@ -97,7 +97,7 @@ If you are planning to use `mc` only on POSIX compatible filesystems, you may sk
9797

9898
To add one or more Amazon S3 compatible hosts, please follow the instructions below. `mc` stores all its configuration information in ``~/.mc/config.json`` file.
9999

100-
```sh
100+
```
101101
mc config host add <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> --api <API-SIGNATURE> --lookup <BUCKET-LOOKUP-TYPE>
102102
```
103103

@@ -108,14 +108,14 @@ Lookup is an optional argument. It is used to indicate whether dns or path style
108108
### Example - MinIO Cloud Storage
109109
MinIO server displays URL, access and secret keys.
110110

111-
```sh
111+
```
112112
mc config host add minio http://192.168.1.51 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
113113
```
114114

115115
### Example - Amazon S3 Cloud Storage
116116
Get your AccessKeyID and SecretAccessKey by following [AWS Credentials Guide](http://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html).
117117

118-
```sh
118+
```
119119
mc config host add s3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
120120
```
121121

@@ -149,7 +149,7 @@ mc config host add s3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo
149149
### Example - Google Cloud Storage
150150
Get your AccessKeyID and SecretAccessKey by following [Google Credentials Guide](https://cloud.google.com/storage/docs/migrating?hl=en#keys)
151151

152-
```sh
152+
```
153153
mc config host add gcs https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
154154
```
155155

@@ -162,7 +162,7 @@ NOTE: Google Cloud Storage only supports Legacy Signature Version 2, so you have
162162

163163
List all buckets from https://play.min.io:9000
164164

165-
```sh
165+
```
166166
mc ls play
167167
[2016-03-22 19:47:48 PDT] 0B my-bucketname/
168168
[2016-03-22 22:01:07 PDT] 0B mytestbucket/
@@ -175,7 +175,7 @@ Make a bucket
175175
`mb` command creates a new bucket.
176176

177177
*Example:*
178-
```sh
178+
```
179179
mc mb play/mybucket
180180
Bucket created successfully `play/mybucket`.
181181
```
@@ -184,7 +184,7 @@ Copy Objects
184184
`cp` command copies data from one or more sources to a target.
185185

186186
*Example:*
187-
```sh
187+
```
188188
mc cp myobject.txt play/mybucket
189189
myobject.txt: 14 B / 14 B ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.00 % 41 B/s 0
190190
```
@@ -197,7 +197,7 @@ myobject.txt: 14 B / 14 B ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
197197
### Shell aliases
198198
You may add shell aliases to override your common Unix tools.
199199

200-
```sh
200+
```
201201
alias ls='mc ls'
202202
alias cp='mc cp'
203203
alias cat='mc cat'
@@ -210,7 +210,7 @@ alias find='mc find'
210210

211211
In case you are using bash or zsh, the current shell will be automatically setup to use completion feature to suggest or auto-complete your mc commands.
212212

213-
```sh
213+
```
214214
mc <TAB>
215215
admin config diff find ls mirror policy session sql update watch
216216
cat cp event head mb pipe rm share stat version

README_zh_CN.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ docker run minio/mc:edge ls play
3939

4040
**注意:** 上述示例默认使用MinIO[演示环境](#test-your-setup)做演示,如果想用`mc`操作其它S3兼容的服务,采用下面的方式来启动容器:
4141

42-
```sh
42+
```
4343
docker run -it --entrypoint=/bin/sh minio/mc
4444
```
4545

@@ -49,7 +49,7 @@ docker run -it --entrypoint=/bin/sh minio/mc
4949
### Homebrew
5050
使用[Homebrew](http://brew.sh/)安装mc。
5151

52-
```sh
52+
```
5353
brew install minio/stable/mc
5454
mc --help
5555
```
@@ -60,7 +60,7 @@ mc --help
6060
| ---------- | -------- |------|
6161
|GNU/Linux|64-bit Intel|https://dl.min.io/client/mc/release/linux-amd64/mc |
6262

63-
```sh
63+
```
6464
chmod +x mc
6565
./mc --help
6666
```
@@ -71,7 +71,7 @@ chmod +x mc
7171
| ---------- | -------- |------|
7272
|Microsoft Windows|64-bit Intel|https://dl.min.io/client/mc/release/windows-amd64/mc.exe |
7373

74-
```sh
74+
```
7575
mc.exe --help
7676
```
7777

@@ -80,7 +80,7 @@ mc.exe --help
8080

8181
如果您没有Golang环境,请参照[如何安装Golang](https://docs.min.io/docs/how-to-install-golang)
8282

83-
```sh
83+
```
8484
go get -d github.com/minio/mc
8585
cd ${GOPATH}/src/github.com/minio/mc
8686
make
@@ -91,7 +91,7 @@ make
9191

9292
添加一个或多个S3兼容的服务,请参考下面说明。`mc`将所有的配置信息都存储在``~/.mc/config.json``文件中。
9393

94-
```sh
94+
```
9595
mc config host add <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> <API-SIGNATURE>
9696
```
9797

@@ -100,21 +100,21 @@ mc config host add <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY
100100
### 示例-MinIO云存储
101101
从MinIO服务获得URL、access key和secret key。
102102

103-
```sh
103+
```
104104
mc config host add minio http://192.168.1.51 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 S3v4
105105
```
106106

107107
### 示例-Amazon S3云存储
108108
参考[AWS Credentials指南](http://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html)获取你的AccessKeyID和SecretAccessKey。
109109

110-
```sh
110+
```
111111
mc config host add s3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 S3v4
112112
```
113113

114114
### 示例-Google云存储
115115
参考[Google Credentials Guide](https://cloud.google.com/storage/docs/migrating?hl=en#keys)获取你的AccessKeyID和SecretAccessKey。
116116

117-
```sh
117+
```
118118
mc config host add gcs https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 S3v2
119119
```
120120

@@ -127,7 +127,7 @@ mc config host add gcs https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V8f1
127127

128128
列出https://play.min.io:9000上的所有存储桶。
129129

130-
```sh
130+
```
131131
mc ls play
132132
[2016-03-22 19:47:48 PDT] 0B my-bucketname/
133133
[2016-03-22 22:01:07 PDT] 0B mytestbucket/
@@ -141,7 +141,7 @@ mc ls play
141141
### Shell别名
142142
你可以添加shell别名来覆盖默认的Unix工具命令。
143143

144-
```sh
144+
```
145145
alias ls='mc ls'
146146
alias cp='mc cp'
147147
alias cat='mc cat'
@@ -153,12 +153,12 @@ alias find='mc find'
153153
### Shell自动补全
154154
你也可以下载[`autocomplete/bash_autocomplete`](https://raw.githubusercontent.com/minio/mc/master/autocomplete/bash_autocomplete)`/etc/bash_completion.d/`,然后将其重命名为`mc`。别忘了在这个文件运行source命令让其在你的当前shell上可用。
155155

156-
```sh
156+
```
157157
sudo wget https://raw.githubusercontent.com/minio/mc/master/autocomplete/bash_autocomplete -O /etc/bash_completion.d/mc
158158
source /etc/bash_completion.d/mc
159159
```
160160

161-
```sh
161+
```
162162
mc <TAB>
163163
admin config diff ls mirror policy session update watch
164164
cat cp events mb pipe rm share version

cmd/admin-heal.go

+16-8
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,29 @@ SCAN MODES:
8585
deep : Heal objects which are missing on one or more disks. Also heal objects with silent data corruption.
8686
8787
EXAMPLES:
88-
1. To format newly replaced disks in a MinIO server with alias 'play'
89-
$ {{.HelpName}} play
88+
1. To format newly replaced disks in a MinIO server with alias 'myminio'
89+
$ {{.HelpName}} myminio
9090
91-
2. Heal 'testbucket' in a MinIO server with alias 'play'
92-
$ {{.HelpName}} play/testbucket/
91+
2. Heal 'testbucket' in a MinIO server with alias 'myminio'
92+
$ {{.HelpName}} myminio/testbucket/
9393
9494
3. Heal all objects under 'dir' prefix
95-
$ {{.HelpName}} --recursive play/testbucket/dir/
95+
$ {{.HelpName}} --recursive myminio/testbucket/dir/
9696
9797
4. Issue a dry-run heal operation to inspect objects health but not heal them
98-
$ {{.HelpName}} --dry-run play
98+
$ {{.HelpName}} --dry-run myminio
9999
100100
5. Issue a dry-run heal operation to inspect objects health under 'dir' prefix
101-
$ {{.HelpName}} --recursive --dry-run play/testbucket/dir/
102-
101+
$ {{.HelpName}} --recursive --dry-run myminio/testbucket/dir/
102+
103+
6. Force start a running heal sequence (meaning it will force kill the running heal sequence and start a new one)
104+
$ {{.HelpName}} --force-start myminio/testbucket/dir/
105+
106+
7. Force stop a running heal sequence (meaning it will force kill the running heal sequence)
107+
$ {{.HelpName}} --force-stop myminio/testbucket/dir/
108+
109+
8. Issue a dry-run heal operation to inspect objects health under 'dir' prefix
110+
$ {{.HelpName}} --dry-run myminio/testbucket/dir/
103111
`,
104112
}
105113

cmd/admin-user-add-policy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
var adminUserPolicyCmd = cli.Command{
27-
Name: "policy",
27+
Name: "set-policy",
2828
Usage: "set policy for user",
2929
Action: mainAdminUserPolicy,
3030
Before: setGlobalsFromContext,

cmd/admin-user-add.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ FLAGS:
4444
{{end}}
4545
EXAMPLES:
4646
1. Add a new user 'foobar' to MinIO server with policy 'writeonly'.
47-
$ set -o history
48-
$ {{.HelpName}} myminio foobar foo12345 writeonly
4947
$ set +o history
48+
$ {{.HelpName}} myminio foobar foo12345 writeonly
49+
$ set -o history
5050
`,
5151
}
5252

cmd/config-host.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525

2626
var configHostCmd = cli.Command{
2727
Name: "host",
28-
Usage: "list, modify and remove hosts in configuration file",
28+
Usage: "add, remove and list hosts in configuration file",
2929
Action: mainConfigHost,
3030
Before: setGlobalsFromContext,
3131
Flags: globalFlags,

cmd/cp-main.go

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ EXAMPLES:
121121
11. Copy a folder recursively from MinIO cloud storage to Amazon S3 cloud storage with specified metadata.
122122
$ {{.HelpName}} --attr key1=value1,key2=value2 --recursive play/mybucket/burningman2011/ s3/mybucket/
123123
124+
12. Copy a text file to an object storage and assign REDUCED_REDUNDANCY storage-class to the uploaded object.
125+
$ {{.HelpName}} --storage-class REDUCED_REDUNDANCY myobject.txt play/mybucket
124126
`,
125127
}
126128

cmd/diff-main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ DESCRIPTION:
5353
It *DOES NOT* compare objects' contents.
5454
5555
LEGEND:
56-
> - object is only in source.
57-
< - object is only in destination.
56+
< - object is only in source.
57+
> - object is only in destination.
5858
! - newer object is in source.
5959
6060
EXAMPLES:

cmd/find-main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ EXAMPLES:
142142
$ {{.HelpName}} s3 --larger 64MB --smaller 1GB --print {url}
143143
144144
08. Find all objects created in the last week under "s3/bucket".
145-
$ {{.HelpName}} s3/bucket --newer 1w
145+
$ {{.HelpName}} s3/bucket --newer-than 7d
146146
147147
09. Find all objects which were created are older than 2 days, 5 hours and 10 minutes and exclude the ones with ".jpg"
148148
extension under "s3".

cmd/mb-main.go

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ EXAMPLES:
6969
7070
6. Create multiple directories including its missing parents (behavior similar to 'mkdir -p').
7171
$ {{.HelpName}} /mnt/sdb/mydisk /mnt/sdc/mydisk /mnt/sdd/mydisk
72+
73+
7. Ignore if bucket/directory already exists.
74+
$ {{.HelpName}} --ignore-existing myminio/mynewbucket
7275
7376
`,
7477
}

cmd/rb-main.go

+7
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,15 @@ func mainRemoveBucket(ctx *cli.Context) error {
235235
if !isForce && !isEmpty {
236236
fatalIf(errDummy().Trace(), "`"+targetURL+"` is not empty. Retry this command with ‘--force’ flag if you want to remove `"+targetURL+"` and all its contents")
237237
}
238+
238239
e := deleteBucket(targetURL)
239240
fatalIf(e.Trace(targetURL), "Failed to remove `"+targetURL+"`.")
241+
242+
if !isNamespaceRemoval(targetURL) {
243+
printMsg(removeBucketMessage{
244+
Bucket: targetURL, Status: "success",
245+
})
246+
}
240247
}
241248
return cErr
242249
}

0 commit comments

Comments
 (0)