empty URI lists top level buckets now & other minor cleanups

This commit is contained in:
Anand Babu (AB) Periasamy
2015-03-12 22:30:51 -07:00
parent 0e558ab3d8
commit ac5a872220
2 changed files with 21 additions and 19 deletions
+2 -3
View File
@@ -49,9 +49,8 @@ var sync = cli.Command{
}
var configure = cli.Command{
Name: "configure",
ShortName: "config",
Usage: "Generate configuration \"" + getMcConfigFilename() + "\" file.",
Name: "config",
Usage: "Generate configuration \"" + getMcConfigFilename() + "\" file.",
Description: `Configure minio client configuration data. If your config
file does not exist (the default location is ~/.auth), it will be
automatically created for you. Note that the configure command only writes
+19 -16
View File
@@ -87,18 +87,21 @@ func getNewClient(c *cli.Context) (*s3.Client, error) {
// Parse global options
func parseGlobalOptions(c *cli.Context) {
switch true {
switch {
case c.Bool("get-bash-completion") == true:
getBashCompletion()
default:
cli.ShowAppHelp(c)
}
}
// Parse subcommand options
func parseOptions(c *cli.Context) (cmdoptions *cmdOptions, err error) {
cmdoptions = new(cmdOptions)
cmdoptions.quiet = c.GlobalBool("quiet")
func parseOptions(c *cli.Context) (cmdopts *cmdOptions, err error) {
cmdopts = new(cmdOptions)
cmdopts.quiet = c.GlobalBool("quiet")
switch len(c.Args()) {
case 0:
return cmdopts, nil
case 1:
if strings.HasPrefix(c.Args().Get(0), "s3://") {
uri, err := url.Parse(c.Args().Get(0))
@@ -108,8 +111,8 @@ func parseOptions(c *cli.Context) (cmdoptions *cmdOptions, err error) {
if uri.Scheme != "s3" {
return nil, errInvalidScheme
}
cmdoptions.source.bucket = uri.Host
cmdoptions.source.key = strings.TrimPrefix(uri.Path, "/")
cmdopts.source.bucket = uri.Host
cmdopts.source.key = strings.TrimPrefix(uri.Path, "/")
} else {
return nil, errInvalidScheme
}
@@ -128,8 +131,8 @@ func parseOptions(c *cli.Context) (cmdoptions *cmdOptions, err error) {
}
return nil, errInvalidScheme
}
cmdoptions.source.bucket = uri.Host
cmdoptions.source.key = strings.TrimPrefix(uri.Path, "/")
cmdopts.source.bucket = uri.Host
cmdopts.source.key = strings.TrimPrefix(uri.Path, "/")
case uri.Scheme == "":
if uri.Host != "" {
return nil, errInvalidScheme
@@ -140,8 +143,8 @@ func parseOptions(c *cli.Context) (cmdoptions *cmdOptions, err error) {
if uri.Path == "." {
return nil, errFskey
}
cmdoptions.source.bucket = uri.Host
cmdoptions.source.key = strings.TrimPrefix(uri.Path, "/")
cmdopts.source.bucket = uri.Host
cmdopts.source.key = strings.TrimPrefix(uri.Path, "/")
case uri.Scheme != "s3":
return nil, errInvalidScheme
}
@@ -159,18 +162,18 @@ func parseOptions(c *cli.Context) (cmdoptions *cmdOptions, err error) {
}
return nil, errInvalidScheme
}
cmdoptions.destination.bucket = uri.Host
cmdoptions.destination.key = strings.TrimPrefix(uri.Path, "/")
cmdopts.destination.bucket = uri.Host
cmdopts.destination.key = strings.TrimPrefix(uri.Path, "/")
case uri.Scheme == "":
if uri.Host != "" {
return nil, errInvalidScheme
}
if uri.Path == "." {
cmdoptions.destination.key = cmdoptions.source.key
cmdopts.destination.key = cmdopts.source.key
} else {
cmdoptions.destination.key = strings.TrimPrefix(uri.Path, "/")
cmdopts.destination.key = strings.TrimPrefix(uri.Path, "/")
}
cmdoptions.destination.bucket = uri.Host
cmdopts.destination.bucket = uri.Host
case uri.Scheme != "s3":
return nil, errInvalidScheme
}