Merge pull request #225 from harshavardhana/pr_out_use_the_new_customhelptemplate_cli_command_option_for_detailed_help

This commit is contained in:
Harshavardhana
2015-04-02 16:09:52 -07:00
5 changed files with 68 additions and 12 deletions
+2 -2
View File
@@ -23,8 +23,8 @@
},
{
"ImportPath": "github.com/minio-io/cli",
"Comment": "1.2.0-100-g6d6f8d3",
"Rev": "6d6f8d3cc162bfcb60379888e2f37d73ff6a6253"
"Comment": "1.2.0-101-g1a25bbd",
"Rev": "1a25bbdce2344b0063ea0476bceb4a4adbe4492a"
},
{
"ImportPath": "github.com/minio-io/donut",
+4
View File
@@ -38,6 +38,10 @@ type Command struct {
HideHelp bool
// Boolean to hide this command from help or completion
Hide bool
// CustomHelpTemplate the text template for the command help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
CustomHelpTemplate string
}
// Invokes the command given the context, parses ctx.Args() to generate command-specific flags
+8 -4
View File
@@ -31,7 +31,7 @@ GLOBAL OPTIONS:
// The text template for the command help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var CommandHelpTemplate = `NAME:
var DefaultCommandHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
@@ -48,7 +48,7 @@ OPTIONS:
// The text template for the subcommand help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var SubcommandHelpTemplate = `NAME:
var DefaultSubcommandHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
@@ -147,7 +147,7 @@ func ShowCommandHelp(c *Context, command string) {
app.Commands = append(app.Commands, command)
}
}
HelpPrinter(SubcommandHelpTemplate, app)
HelpPrinter(DefaultSubcommandHelpTemplate, app)
return
}
@@ -161,7 +161,11 @@ func ShowCommandHelp(c *Context, command string) {
c0.Flags = append(c0.Flags, flag)
}
}
HelpPrinter(CommandHelpTemplate, c0)
if c0.CustomHelpTemplate != "" {
HelpPrinter(c0.CustomHelpTemplate, c0)
} else {
HelpPrinter(DefaultCommandHelpTemplate, c0)
}
return
}
}
+1 -1
View File
@@ -62,7 +62,7 @@ docs-deploy:
install: test-all
@echo "Installing mc:"
@godep go install github.com/minio-io/mc
@godep go install -a github.com/minio-io/mc
@mkdir -p $(HOME)/.minio/mc
clean:
+53 -5
View File
@@ -24,22 +24,70 @@ import (
var cpCmd = cli.Command{
Name: "cp",
Usage: "copy objects",
Description: `Copies a local file or dir or object or bucket to another location locally or in S3.`,
Usage: "copy objects and files",
Description: "Copy files and objects recursively between Amazon S3, Donut and Filesystem",
Action: doCopyCmd,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "recursive, r",
Usage: "recursively crawls given directory uploads to given bucket",
Usage: "recursively crawls a given directory or bucket",
},
},
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
USAGE:
mc {{.Name}}{{if .Flags}} [ARGS...]{{end}} SOURCE TARGET [TARGET...] {{if .Description}}
DESCRIPTION:
{{.Description}}{{end}}{{if .Flags}}
OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{ end }}
EXAMPLES:
1. Copy an object from Amazon S3 object storage to local fileystem.
$ mc {{.Name}} https://s3.amazonaws.com/jukebox/klingon_opera_aktuh_maylotah.ogg wakeup.ogg
2. Copy a bucket recursive from Donut to Amazon S3 object storage
$ mc {{.Name}} --recursive donut://home/photos/burningman2011 https://s3.amazonaws.com/burningman/
3. Copy a local folder to Donut and Amazon S3 object storage
$ mc {{.Name}} --recursive backup/ donut://archive/backup/ https://s3.amazonaws.com/backup/
`,
}
var lsCmd = cli.Command{
Name: "ls",
Usage: "get list of objects",
Description: `List Objects and common prefixes under a prefix or all Buckets`,
Usage: "list files and objects",
Description: `List files and objects recursively between Amazon S3, Donut and Filesystem`,
Action: doListCmd,
CustomHelpTemplate: `NAME:
mc {{.Name}} - {{.Usage}}
USAGE:
mc {{.Name}} TARGET {{if .Description}}
DESCRIPTION:
{{.Description}}{{end}}{{if .Flags}}
OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{ end }}
EXAMPLES:
1. List objects on Donut storage
$ mc {{.Name}} donut://archive/backup/
2015-03-28 12:47:50 PDT 51.00 MB 2006-Jan-1/backup.tar.gz
2015-03-31 14:46:33 PDT 55.00 MB 2006-Mar-1/backup.tar.gz
2. List buckets on Amazon S3 object storage
$ mc {{.Name}} https://s3.amazonaws.com/
2015-01-20 15:42:00 PST rom
2015-01-15 00:05:40 PST zek
`,
}
var mbCmd = cli.Command{