Merge pull request #1326 from abperiasamy/help-fixes

fixes related to help handling
This commit is contained in:
Anand Babu (AB) Periasamy
2015-11-15 20:11:13 -08:00
8 changed files with 35 additions and 40 deletions
+10 -6
View File
@@ -30,7 +30,7 @@ import "github.com/minio/cli"
//
var configCmd = cli.Command{
Name: "config",
Usage: "Manage ‘mc’ configuration.",
Usage: "Manage configuration file.",
Action: mainConfig,
Subcommands: []cli.Command{
configAliasCmd,
@@ -38,20 +38,24 @@ var configCmd = cli.Command{
configVersionCmd,
},
CustomHelpTemplate: `NAME:
{{.Name}} - {{.Usage}}
mc {{.Name}} - {{.Usage}}
USAGE:
{{.Name}} {{if .Flags}}[global flags] {{end}}command{{if .Flags}} [command flags]{{end}} [arguments...]
mc {{.Name}} COMMAND
COMMANDS:
{{range .Commands}}{{ .Name }}{{ "\t" }}{{.Usage}}
{{range .Subcommands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
{{end}}
`,
}
// mainConfig is the handle for "mc config" command. provides sub-commands which write configuration data in json format to config file.
func mainConfig(ctx *cli.Context) {
if !ctx.Args().Present() {
cli.ShowAppHelp(ctx)
if ctx.Args().First() != "" { // command help.
cli.ShowCommandHelp(ctx, ctx.Args().First())
} else { // mc help.
cli.ShowSubcommandHelp(ctx)
}
// sub-commands like "upload" and "download" have their own main.
}
+1 -1
View File
@@ -43,7 +43,7 @@ var cpCmd = cli.Command{
mc {{.Name}} - {{.Usage}}
USAGE:
mc {{.Name}} [OPTIONS] SOURCE [SOURCE...] TARGET
mc {{.Name}} SOURCE [SOURCE...] TARGET
EXAMPLES:
1. Copy a list of objects from local file system to Amazon S3 cloud storage.
-10
View File
@@ -38,18 +38,8 @@ EXAMPLES:
`,
}
// Validate command line arguments.
func checkHelpSyntax(ctx *cli.Context) {
if len(ctx.Args()) > 1 { // Accepts a maximum of 1 argument.
exitCode := 1
cli.ShowCommandHelpAndExit(ctx, "help", exitCode)
}
}
// main for help command.
func mainHelp(ctx *cli.Context) {
checkHelpSyntax(ctx)
if ctx.Args().First() != "" { // command help.
cli.ShowCommandHelp(ctx, ctx.Args().First())
} else { // mc help.
+4 -4
View File
@@ -43,11 +43,11 @@ var lsCmd = cli.Command{
mc {{.Name}} - {{.Usage}}
USAGE:
mc {{.Name}} [OPTIONS] TARGET [TARGET ...]
OPTIONS:
--incomplete - List incomplete upload of objects.
mc {{.Name}} [FLAGS] TARGET [TARGET ...]
FLAGS:
{{range .Flags}}{{.}}
{{end}}
EXAMPLES:
1. List buckets on Amazon S3 cloud storage.
$ mc {{.Name}} https://s3.amazonaws.com/
+4 -4
View File
@@ -51,11 +51,11 @@ var mirrorCmd = cli.Command{
mc {{.Name}} - {{.Usage}}
USAGE:
mc {{.Name}} [OPTIONS] SOURCE TARGET [TARGET...]
OPTIONS:
--force - Force overwrite of an existing target(s).
mc {{.Name}} [FLAGS] SOURCE TARGET [TARGET...]
FLAGS:
{{range .Flags}}{{.}}
{{end}}
EXAMPLES:
1. Mirror a bucket recursively from Minio cloud storage to a bucket on Amazon S3 cloud storage.
$ mc {{.Name}} https://play.minio.io:9000/photos/2014 https://s3.amazonaws.com/backup-photos
+5 -6
View File
@@ -37,7 +37,7 @@ var (
rmFlagIncomplete = cli.BoolFlag{
Name: "incomplete, I",
Usage: "remove incomplete uploads.",
Usage: "Remove an incomplete upload(s).",
}
)
@@ -51,12 +51,11 @@ var rmCmd = cli.Command{
mc {{.Name}} - {{.Usage}}
USAGE:
mc {{.Name}} [OPTIONS] TARGET [TARGET ...]
OPTIONS:
--force - Force a dangerous remove operation.
--incomplete - Remove incomplete uploads.
mc {{.Name}} [FLAGS] TARGET [TARGET ...]
FLAGS:
{{range .Flags}}{{.}}
{{end}}
EXAMPLES:
1. Remove an object.
$ mc {{.Name}} https://s3.amazonaws.com/jazz-songs/louis/file01.mp3
+5 -5
View File
@@ -41,17 +41,17 @@ USAGE:
mc {{.Name}} resume SESSION-ID
mc {{.Name}} clear SESSION-ID
SESSION-ID = $SESSION | all
SESSION-ID:
SESSION - Session can either be $SESSION-ID or "all".
EXAMPLES:
1. List sessions
1. List sessions.
$ mc {{.Name}} list
ygVIpSJs -> [2015-08-29 15:25:12 PDT] cp /usr/bin... test
2. Resume session
2. Resume session.
$ mc {{.Name}} resume ygVIpSJs
3. Clear session
3. Clear session.
$ mc {{.Name}} clear ygVIpSJs
`,
}
+6 -4
View File
@@ -36,10 +36,10 @@ var shareCmd = cli.Command{
shareList,
},
CustomHelpTemplate: `NAME:
{{.Name}} - {{.Usage}}
mc {{.Name}} - {{.Usage}}
USAGE:
{{.Name}} command [arguments...]
mc {{.Name}} [COMMAND]
COMMANDS:
{{range .Subcommands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
@@ -65,8 +65,10 @@ func migrateShare() {
// mainShare - main handler for mc share command
func mainShare(ctx *cli.Context) {
if !ctx.Args().Present() || ctx.Args().First() == "help" {
cli.ShowAppHelp(ctx)
if ctx.Args().First() != "" { // command help.
cli.ShowCommandHelp(ctx, ctx.Args().First())
} else { // mc help.
cli.ShowSubcommandHelp(ctx)
}
// sub-commands like "upload" and "download" have their own main.