Skip to content

Commit

Permalink
mc command cleanup (minio#2783)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinhaashish authored and nitisht committed Jun 27, 2019
1 parent 2d69150 commit 56309a4
Show file tree
Hide file tree
Showing 22 changed files with 321 additions and 270 deletions.
2 changes: 1 addition & 1 deletion CONFLICT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Besides `mc` is a single static binary and can reside inside your application an

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.

```sh
```
mv ./mc ./mcli
```
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Setup your mc Github Repository
Fork [mc upstream](https://github.com/minio/mc/fork) source repository to your own personal repository.
```sh
```
$ mkdir -p $GOPATH/src/github.com/minio
$ cd $GOPATH/src/github.com/minio
$ git clone https://github.com/$USER_ID/mc
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ docker run minio/mc:edge ls play

**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:

```sh
```
docker run -it --entrypoint=/bin/sh minio/mc
```

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

```sh
```
brew install minio/stable/mc
mc --help
```
Expand All @@ -65,7 +65,7 @@ mc --help
|GNU/Linux|64-bit Intel|https://dl.min.io/client/mc/release/linux-amd64/mc |
||64-bit PPC|https://dl.min.io/client/mc/release/linux-ppc64le/mc |

```sh
```
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
./mc --help
Expand All @@ -77,7 +77,7 @@ chmod +x mc
| ---------- | -------- |------|
|Microsoft Windows|64-bit Intel|https://dl.min.io/client/mc/release/windows-amd64/mc.exe |

```sh
```
mc.exe --help
```

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

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

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

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.

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

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

```sh
```
mc config host add minio http://192.168.1.51 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
```

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

```sh
```
mc config host add s3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
```

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

```sh
```
mc config host add gcs https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
```

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

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

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

*Example:*
```sh
```
mc mb play/mybucket
Bucket created successfully `play/mybucket`.
```
Expand All @@ -184,7 +184,7 @@ Copy Objects
`cp` command copies data from one or more sources to a target.

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

```sh
```
alias ls='mc ls'
alias cp='mc cp'
alias cat='mc cat'
Expand All @@ -210,7 +210,7 @@ alias find='mc find'

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.

```sh
```
mc <TAB>
admin config diff find ls mirror policy session sql update watch
cat cp event head mb pipe rm share stat version
Expand Down
26 changes: 13 additions & 13 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ docker run minio/mc:edge ls play

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

```sh
```
docker run -it --entrypoint=/bin/sh minio/mc
```

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

```sh
```
brew install minio/stable/mc
mc --help
```
Expand All @@ -60,7 +60,7 @@ mc --help
| ---------- | -------- |------|
|GNU/Linux|64-bit Intel|https://dl.min.io/client/mc/release/linux-amd64/mc |

```sh
```
chmod +x mc
./mc --help
```
Expand All @@ -71,7 +71,7 @@ chmod +x mc
| ---------- | -------- |------|
|Microsoft Windows|64-bit Intel|https://dl.min.io/client/mc/release/windows-amd64/mc.exe |

```sh
```
mc.exe --help
```

Expand All @@ -80,7 +80,7 @@ mc.exe --help

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

```sh
```
go get -d github.com/minio/mc
cd ${GOPATH}/src/github.com/minio/mc
make
Expand All @@ -91,7 +91,7 @@ make

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

```sh
```
mc config host add <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> <API-SIGNATURE>
```

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

```sh
```
mc config host add minio http://192.168.1.51 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 S3v4
```

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

```sh
```
mc config host add s3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 S3v4
```

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

```sh
```
mc config host add gcs https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 S3v2
```

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

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

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

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

```sh
```
sudo wget https://raw.githubusercontent.com/minio/mc/master/autocomplete/bash_autocomplete -O /etc/bash_completion.d/mc
source /etc/bash_completion.d/mc
```

```sh
```
mc <TAB>
admin config diff ls mirror policy session update watch
cat cp events mb pipe rm share version
Expand Down
24 changes: 16 additions & 8 deletions cmd/admin-heal.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,29 @@ SCAN MODES:
deep : Heal objects which are missing on one or more disks. Also heal objects with silent data corruption.
EXAMPLES:
1. To format newly replaced disks in a MinIO server with alias 'play'
$ {{.HelpName}} play
1. To format newly replaced disks in a MinIO server with alias 'myminio'
$ {{.HelpName}} myminio
2. Heal 'testbucket' in a MinIO server with alias 'play'
$ {{.HelpName}} play/testbucket/
2. Heal 'testbucket' in a MinIO server with alias 'myminio'
$ {{.HelpName}} myminio/testbucket/
3. Heal all objects under 'dir' prefix
$ {{.HelpName}} --recursive play/testbucket/dir/
$ {{.HelpName}} --recursive myminio/testbucket/dir/
4. Issue a dry-run heal operation to inspect objects health but not heal them
$ {{.HelpName}} --dry-run play
$ {{.HelpName}} --dry-run myminio
5. Issue a dry-run heal operation to inspect objects health under 'dir' prefix
$ {{.HelpName}} --recursive --dry-run play/testbucket/dir/
$ {{.HelpName}} --recursive --dry-run myminio/testbucket/dir/
6. Force start a running heal sequence (meaning it will force kill the running heal sequence and start a new one)
$ {{.HelpName}} --force-start myminio/testbucket/dir/
7. Force stop a running heal sequence (meaning it will force kill the running heal sequence)
$ {{.HelpName}} --force-stop myminio/testbucket/dir/
8. Issue a dry-run heal operation to inspect objects health under 'dir' prefix
$ {{.HelpName}} --dry-run myminio/testbucket/dir/
`,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/admin-user-add-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

var adminUserPolicyCmd = cli.Command{
Name: "policy",
Name: "set-policy",
Usage: "set policy for user",
Action: mainAdminUserPolicy,
Before: setGlobalsFromContext,
Expand Down
4 changes: 2 additions & 2 deletions cmd/admin-user-add.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ FLAGS:
{{end}}
EXAMPLES:
1. Add a new user 'foobar' to MinIO server with policy 'writeonly'.
$ set -o history
$ {{.HelpName}} myminio foobar foo12345 writeonly
$ set +o history
$ {{.HelpName}} myminio foobar foo12345 writeonly
$ set -o history
`,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/config-host.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

var configHostCmd = cli.Command{
Name: "host",
Usage: "list, modify and remove hosts in configuration file",
Usage: "add, remove and list hosts in configuration file",
Action: mainConfigHost,
Before: setGlobalsFromContext,
Flags: globalFlags,
Expand Down
2 changes: 2 additions & 0 deletions cmd/cp-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ EXAMPLES:
11. Copy a folder recursively from MinIO cloud storage to Amazon S3 cloud storage with specified metadata.
$ {{.HelpName}} --attr key1=value1,key2=value2 --recursive play/mybucket/burningman2011/ s3/mybucket/
12. Copy a text file to an object storage and assign REDUCED_REDUNDANCY storage-class to the uploaded object.
$ {{.HelpName}} --storage-class REDUCED_REDUNDANCY myobject.txt play/mybucket
`,
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/diff-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ DESCRIPTION:
It *DOES NOT* compare objects' contents.
LEGEND:
> - object is only in source.
< - object is only in destination.
< - object is only in source.
> - object is only in destination.
! - newer object is in source.
EXAMPLES:
Expand Down
2 changes: 1 addition & 1 deletion cmd/find-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ EXAMPLES:
$ {{.HelpName}} s3 --larger 64MB --smaller 1GB --print {url}
08. Find all objects created in the last week under "s3/bucket".
$ {{.HelpName}} s3/bucket --newer 1w
$ {{.HelpName}} s3/bucket --newer-than 7d
09. Find all objects which were created are older than 2 days, 5 hours and 10 minutes and exclude the ones with ".jpg"
extension under "s3".
Expand Down
3 changes: 3 additions & 0 deletions cmd/mb-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ EXAMPLES:
6. Create multiple directories including its missing parents (behavior similar to 'mkdir -p').
$ {{.HelpName}} /mnt/sdb/mydisk /mnt/sdc/mydisk /mnt/sdd/mydisk
7. Ignore if bucket/directory already exists.
$ {{.HelpName}} --ignore-existing myminio/mynewbucket
`,
}
Expand Down
7 changes: 7 additions & 0 deletions cmd/rb-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,15 @@ func mainRemoveBucket(ctx *cli.Context) error {
if !isForce && !isEmpty {
fatalIf(errDummy().Trace(), "`"+targetURL+"` is not empty. Retry this command with ‘--force’ flag if you want to remove `"+targetURL+"` and all its contents")
}

e := deleteBucket(targetURL)
fatalIf(e.Trace(targetURL), "Failed to remove `"+targetURL+"`.")

if !isNamespaceRemoval(targetURL) {
printMsg(removeBucketMessage{
Bucket: targetURL, Status: "success",
})
}
}
return cErr
}
Loading

0 comments on commit 56309a4

Please sign in to comment.