list: Move incomplete as last argument.

implement args.Head() to handle this case smoothly.
This commit is contained in:
Harshavardhana
2015-11-06 16:17:15 -08:00
parent 9f206f590f
commit 8de841cd69
4 changed files with 17 additions and 6 deletions
+3 -3
View File
@@ -65,7 +65,7 @@ EXAMPLES:
[2015-05-19 17:28:22 PDT] 41B 本語.md
7. List incompletely uploaded files for a given bucket
$ mc ls incomplete s3/miniocloud
$ mc ls s3/miniocloud incomplete
[2015-10-19 22:28:02 PDT] 0B bin/
`,
@@ -126,8 +126,8 @@ func mainList(ctx *cli.Context) {
var targetURLs []string
var err *probe.Error
if args.First() == "incomplete" {
targetURLs, err = args2URLs(args.Tail())
if args.Last() == "incomplete" {
targetURLs, err = args2URLs(args.Head())
fatalIf(err.Trace(args...), "One or more unknown URL types passed.")
for _, targetURL := range targetURLs {
// if recursive strip off the "..."
+3 -1
View File
@@ -19,8 +19,10 @@ import (
type App struct {
// The name of the program. Defaults to os.Args[0]
Name string
// Description of the program.
// Usage of the program.
Usage string
// Description of the program.
Description string
// Version of the program
Version string
// List of commands to execute
+9
View File
@@ -193,6 +193,15 @@ func (a Args) Tail() Args {
return []string{}
}
// Head - Return the rest of the arguments (not the last one)
// or else an empty string slice
func (a Args) Head() Args {
if len(a) == 1 {
return a
}
return []string(a)[:len(a)-1]
}
// Present - Checks if there are any arguments present
func (a Args) Present() bool {
return len(a) != 0
+2 -2
View File
@@ -24,8 +24,8 @@
},
{
"path": "github.com/minio/cli",
"revision": "20bcbfd3118387fcf8e29dd3c45bff0c13de2a01",
"revisionTime": "2015-09-05T22:26:54-07:00"
"revision": "deb83e228f8fd55ca51942e0de0ec09665b3f63c",
"revisionTime": "2015-11-06T16:14:14-08:00"
},
{
"path": "github.com/minio/minio-go",