Fix tree docs and error handling (#2833)

Fixes #2832
This commit is contained in:
Harshavardhana
2019-07-22 13:02:49 -07:00
committed by kannappanr
parent c727be5a48
commit c25461640b
2 changed files with 16 additions and 18 deletions
+12 -17
View File
@@ -66,6 +66,7 @@ var treeFlags = []cli.Flag{
cli.IntFlag{
Name: "depth, d",
Usage: "sets the depth threshold",
Value: -1,
},
}
@@ -86,23 +87,20 @@ FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
EXAMPLES:
1. List all buckets on Amazon S3 cloud storage in a tree format..
$ {{.HelpName}} s3
1. List all buckets and directories on MinIO object storage server in tree format.
$ {{.HelpName}} myminio
2. List all buckets in "mybucket" on Amazon S3 cloud storage in a tree format.
$ {{.HelpName}} s3/mybucket/
2. List all directories in "mybucket" on MinIO object storage server in tree format.
$ {{.HelpName}} myminio/mybucket/
3. List all buckets in "mybucket" on Amazon S3 cloud storage hosted on Microsoft Windows in a tree format.
$ {{.HelpName}} s3\mybucket\
3. List all directories in "mybucket" on MinIO object storage server hosted on Microsoft Windows in tree format.
$ {{.HelpName}} myminio\mybucket\
4. List all buckets and objects in "mybucket" on Amazon S3 cloud storage in a tree format.
4. List all directories and objects in "mybucket" on MinIO object storage server in tree format.
$ {{.HelpName}} --files myminio/mybucket/
5. Set the depth of the tree for listing.
5. List all directories upto depth level '2' in tree format.
$ {{.HelpName}} --depth 2 myminio/mybucket/
6. List all the directories irrespective to the depth.
$ {{.HelpName}} myminio/mybucket/
`,
}
@@ -111,8 +109,8 @@ func checkTreeSyntax(ctx *cli.Context) {
args := ctx.Args()
if ctx.IsSet("depth") {
if ctx.Int("depth") <= 0 {
fatalIf(errInvalidArgument().Trace(args...), "depth should have a value greater than 0")
if ctx.Int("depth") < -1 || ctx.Int("depth") == 0 {
fatalIf(errInvalidArgument().Trace(args...), "please set a proper depth, for example: '--depth 1' to limit the tree output, default (-1) output displays everything")
}
}
@@ -263,10 +261,7 @@ func mainTree(ctx *cli.Context) error {
}
includeFiles := ctx.Bool("files")
depth := -1
if ctx.IsSet("depth") {
depth = ctx.Int("depth")
}
depth := ctx.Int("depth")
var cErr error
for _, targetURL := range args {
+4 -1
View File
@@ -11,9 +11,11 @@ require (
github.com/gorilla/websocket v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-version v1.1.0
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c // indirect
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03 // indirect
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.1
github.com/mattn/go-isatty v0.0.7
@@ -32,11 +34,12 @@ require (
github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 // indirect
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/ugorji/go/codec v1.1.5-pre // indirect
github.com/ugorji/go v1.1.5-pre // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
go.uber.org/multierr v1.1.0 // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/net v0.0.0-20190628185345-da137c7871d7
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 // indirect
golang.org/x/text v0.3.2
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect