organize global flags after cmd flag

This commit is contained in:
Anand Babu (AB) Periasamy
2015-11-24 16:59:46 -08:00
parent de760d4efb
commit 8fc138f3a0
20 changed files with 169 additions and 127 deletions
+6 -4
View File
@@ -27,9 +27,11 @@ import (
)
var (
accessFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of access.",
accessFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of access.",
},
}
)
@@ -38,7 +40,7 @@ var accessCmd = cli.Command{
Name: "access",
Usage: "Manage bucket access permissions.",
Action: mainAccess,
Flags: append(globalFlags, accessFlagHelp),
Flags: append(accessFlags, globalFlags...),
CustomHelpTemplate: `Name:
mc {{.Name}} - {{.Usage}}
+6 -4
View File
@@ -31,9 +31,11 @@ import (
)
var (
catFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of cat",
catFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of cat",
},
}
)
@@ -42,7 +44,7 @@ var catCmd = cli.Command{
Name: "cat",
Usage: "Display contents of a file.",
Action: mainCat,
Flags: append(globalFlags, catFlagHelp),
Flags: append(catFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
+6 -4
View File
@@ -28,9 +28,11 @@ import (
)
var (
configAliasFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of config alias.",
configAliasFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of config alias.",
},
}
)
@@ -38,7 +40,7 @@ var configAliasCmd = cli.Command{
Name: "alias",
Usage: "List, modify and remove aliases in configuration file.",
Action: mainConfigAlias,
Flags: append(globalFlags, configAliasFlagHelp),
Flags: append(configAliasFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc config {{.Name}} - {{.Usage}}
+6 -4
View File
@@ -28,16 +28,18 @@ import (
)
var (
configHostFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of config host",
configHostFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of config host",
},
}
)
var configHostCmd = cli.Command{
Name: "host",
Usage: "List, modify and remove hosts in configuration file.",
Flags: append(globalFlags, configHostFlagHelp),
Flags: append(configHostFlags, globalFlags...),
Action: mainConfigHost,
CustomHelpTemplate: `NAME:
mc config {{.Name}} - {{.Usage}}
+6 -4
View File
@@ -30,9 +30,11 @@ import "github.com/minio/cli"
//
var (
configFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of config.",
configFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of config.",
},
}
)
@@ -40,7 +42,7 @@ var configCmd = cli.Command{
Name: "config",
Usage: "Manage configuration file.",
Action: mainConfig,
Flags: append(globalFlags, configFlagHelp),
Flags: append(configFlags, globalFlags...),
Subcommands: []cli.Command{
configAliasCmd,
configHostCmd,
+6 -4
View File
@@ -25,9 +25,11 @@ import (
)
var (
configVersionFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of config version",
configVersionFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of config version",
},
}
)
@@ -36,7 +38,7 @@ var configVersionCmd = cli.Command{
Name: "version",
Usage: "Print config version.",
Action: mainConfigVersion,
Flags: append(globalFlags, configVersionFlagHelp),
Flags: append(configVersionFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc config {{.Name}} - {{.Usage}}
+10 -8
View File
@@ -38,13 +38,15 @@ import (
// cp command flags.
var (
cpFlagRecursive = cli.BoolFlag{
Name: "recursive, r",
Usage: "Copy recursively.",
}
cpFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of cp.",
cpFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of cp.",
},
cli.BoolFlag{
Name: "recursive, r",
Usage: "Copy recursively.",
},
}
)
@@ -53,7 +55,7 @@ var cpCmd = cli.Command{
Name: "cp",
Usage: "Copy one or more objects to a target.",
Action: mainCopy,
Flags: append(globalFlags, cpFlagRecursive, cpFlagHelp),
Flags: append(cpFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
+6 -4
View File
@@ -30,9 +30,11 @@ import (
// diff specific flags.
var (
diffFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of diff.",
diffFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of diff.",
},
}
)
@@ -42,7 +44,7 @@ var diffCmd = cli.Command{
Usage: "Compute differences between two folders.",
Description: "Diff only lists missing objects or objects with size differences. It *DOES NOT* compare contents. i.e. Objects of same name and size, but differ in contents are not noticed.",
Action: mainDiff,
Flags: append(globalFlags, diffFlagHelp),
Flags: append(diffFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
+14 -12
View File
@@ -28,17 +28,19 @@ import (
// ls specific flags.
var (
lsFlagRecursive = cli.BoolFlag{
Name: "recursive, r",
Usage: "List recursively.",
}
lsFlagIncomplete = cli.BoolFlag{
Name: "incomplete, I",
Usage: "Remove incomplete uploads.",
}
lsFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of ls.",
lsFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of ls.",
},
cli.BoolFlag{
Name: "recursive, r",
Usage: "List recursively.",
},
cli.BoolFlag{
Name: "incomplete, I",
Usage: "Remove incomplete uploads.",
},
}
)
@@ -47,7 +49,7 @@ var lsCmd = cli.Command{
Name: "ls",
Usage: "List files and folders.",
Action: mainList,
Flags: append(globalFlags, lsFlagRecursive, lsFlagIncomplete, lsFlagHelp),
Flags: append(lsFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
+6 -4
View File
@@ -27,9 +27,11 @@ import (
)
var (
mbFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of mb.",
mbFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of mb.",
},
}
)
@@ -38,7 +40,7 @@ var mbCmd = cli.Command{
Name: "mb",
Usage: "Make a bucket or folder.",
Action: mainMakeBucket,
Flags: append(globalFlags, mbFlagHelp),
Flags: append(mbFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
+10 -8
View File
@@ -37,13 +37,15 @@ import (
// mirror specific flags.
var (
mirrorFlagForce = cli.BoolFlag{
Name: "force",
Usage: "Force overwrite of an existing target(s).",
}
mirrorFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of mirror.",
mirrorFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of mirror.",
},
cli.BoolFlag{
Name: "force",
Usage: "Force overwrite of an existing target(s).",
},
}
)
@@ -52,7 +54,7 @@ var mirrorCmd = cli.Command{
Name: "mirror",
Usage: "Mirror folders recursively from a single source to many destinations.",
Action: mainMirror,
Flags: append(globalFlags, mirrorFlagForce, mirrorFlagHelp),
Flags: append(mirrorFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
+6 -4
View File
@@ -25,9 +25,11 @@ import (
)
var (
pipeFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of pipe.",
pipeFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of pipe.",
},
}
)
@@ -36,7 +38,7 @@ var pipeCmd = cli.Command{
Name: "pipe",
Usage: "Write contents of stdin to one or more targets. When no target is specified, it writes to stdout.",
Action: mainPipe,
Flags: append(globalFlags, pipeFlagHelp),
Flags: append(pipeFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
+22 -20
View File
@@ -29,25 +29,27 @@ import (
// rm specific flags.
var (
rmFlagRecursive = cli.BoolFlag{
Name: "recursive, r",
Usage: "Remove recursively.",
}
rmFlagForce = cli.BoolFlag{
Name: "force",
Usage: "Force a dangerous remove operation.",
}
rmFlagIncomplete = cli.BoolFlag{
Name: "incomplete, I",
Usage: "Remove an incomplete upload(s).",
}
rmFlagFake = cli.BoolFlag{
Name: "fake",
Usage: "Perform a fake remove operation.",
}
rmFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of rm.",
rmFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of rm.",
},
cli.BoolFlag{
Name: "recursive, r",
Usage: "Remove recursively.",
},
cli.BoolFlag{
Name: "force",
Usage: "Force a dangerous remove operation.",
},
cli.BoolFlag{
Name: "incomplete, I",
Usage: "Remove an incomplete upload(s).",
},
cli.BoolFlag{
Name: "fake",
Usage: "Perform a fake remove operation.",
},
}
)
@@ -56,7 +58,7 @@ var rmCmd = cli.Command{
Name: "rm",
Usage: "Remove file or bucket [WARNING: Use with care].",
Action: mainRm,
Flags: append(globalFlags, rmFlagRecursive, rmFlagForce, rmFlagIncomplete, rmFlagFake, rmFlagHelp),
Flags: append(rmFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
+6 -4
View File
@@ -30,9 +30,11 @@ import (
)
var (
sessionFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of session.",
sessionFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of session.",
},
}
)
@@ -41,7 +43,7 @@ var sessionCmd = cli.Command{
Name: "session",
Usage: "Manage saved sessions of cp and mirror operations.",
Action: mainSession,
Flags: append(globalFlags, sessionFlagHelp),
Flags: append(sessionFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
+11 -8
View File
@@ -24,13 +24,16 @@ import (
)
var (
shareFlagDownloadHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of share download",
}
shareFlagDownloadRecursive = cli.BoolFlag{
Name: "recursive, r",
Usage: "Share all objects recursively.",
shareDownloadFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of share download",
},
cli.BoolFlag{
Name: "recursive, r",
Usage: "Share all objects recursively.",
},
shareFlagExpire,
}
)
@@ -39,7 +42,7 @@ var shareDownload = cli.Command{
Name: "download",
Usage: "Generate URLs for download access.",
Action: mainShareDownload,
Flags: append(globalFlags, shareFlagExpire, shareFlagDownloadHelp, shareFlagDownloadRecursive),
Flags: append(shareDownloadFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc share {{.Name}} - {{.Usage}}
+6 -4
View File
@@ -25,9 +25,11 @@ import (
)
var (
shareFlagListHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of share list.",
shareListFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of share list.",
},
}
)
@@ -36,7 +38,7 @@ var shareList = cli.Command{
Name: "list",
Usage: "List previously shared objects and folders.",
Action: mainShareList,
Flags: append(globalFlags, shareFlagListHelp),
Flags: append(shareListFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc share {{.Name}} COMMAND - {{.Usage}}
+6 -4
View File
@@ -26,9 +26,11 @@ import (
)
var (
shareFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of share.",
shareFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of share.",
},
}
)
@@ -37,7 +39,7 @@ var shareCmd = cli.Command{
Name: "share",
Usage: "Generate URL for sharing.",
Action: mainShare,
Flags: append(globalFlags, shareFlagHelp),
Flags: append(shareFlags, globalFlags...),
Subcommands: []cli.Command{
shareDownload,
shareUpload,
+14 -10
View File
@@ -27,13 +27,17 @@ import (
)
var (
shareFlagUploadHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help of share download.",
}
shareFlagUploadStartsWith = cli.BoolFlag{
Name: "starts-with",
Usage: "Enable to upload to a particular key prefix.",
shareUploadFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help of share download.",
},
cli.BoolFlag{
Name: "recursive, r",
Usage: "Recursively upload any object matching the prefix recursively.",
},
shareFlagExpire,
shareFlagContentType,
}
)
@@ -42,7 +46,7 @@ var shareUpload = cli.Command{
Name: "upload",
Usage: "Generate ‘curl’ command to upload objects without requiring access/secret keys.",
Action: mainShareUpload,
Flags: append(globalFlags, shareFlagExpire, shareFlagContentType, shareFlagUploadHelp, shareFlagUploadStartsWith),
Flags: append(shareUploadFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc share {{.Name}} - {{.Usage}}
@@ -62,8 +66,8 @@ EXAMPLES:
3. Generate a curl command to allow upload access of only '.png' images to a folder. Command expires in 2 hours.
$ mc share {{.Name}} --expire=2h --content-type=image/png s3.amazonaws.com/backup/2007-Mar-2/
4. Generate a curl command to allow upload access of only objects with key prefix 'backup'. Command expires in 2 hours.
$ mc share {{.Name}} --starts-with --expire=2h s3.amazonaws.com/backup/2007-Mar-2/backup
4. Generate a curl command to allow upload access to any objects matching the key prefix 'backup'. Command expires in 2 hours.
$ mc share {{.Name}} --recursive --expire=2h s3.amazonaws.com/backup/2007-Mar-2/backup
`,
}
+10 -9
View File
@@ -30,14 +30,15 @@ import (
// command specific flags.
var (
updateFlagExperimental = cli.BoolFlag{
Name: "experimental, E",
Usage: "Check experimental update.",
}
updateFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help for update.",
updateFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help for update.",
},
cli.BoolFlag{
Name: "experimental, E",
Usage: "Check experimental update.",
},
}
)
@@ -46,7 +47,7 @@ var updateCmd = cli.Command{
Name: "update",
Usage: "Check for a new software update.",
Action: mainUpdate,
Flags: append(globalFlags, updateFlagExperimental, updateFlagHelp),
Flags: append(updateFlags, globalFlags...),
CustomHelpTemplate: `Name:
mc {{.Name}} - {{.Usage}}
+6 -4
View File
@@ -27,9 +27,11 @@ import (
)
var (
versionFlagHelp = cli.BoolFlag{
Name: "help, h",
Usage: "Help for version.",
versionFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Help for version.",
},
}
)
@@ -38,7 +40,7 @@ var versionCmd = cli.Command{
Name: "version",
Usage: "Print version.",
Action: mainVersion,
Flags: append(globalFlags, versionFlagHelp),
Flags: append(versionFlags, globalFlags...),
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}