diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 83d322dec3..73dabefd35 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -2,6 +2,11 @@ "ImportPath": "github.com/googlecloudplatform/gcsfuse", "GoVersion": "devel", "Deps": [ + { + "ImportPath": "github.com/codegangsta/cli", + "Comment": "1.2.0-137-gbca61c4", + "Rev": "bca61c476e3c752594983e4c9bcd5f62fb09f157" + }, { "ImportPath": "github.com/jacobsa/fuse", "Rev": "c968295acdae6a4a78ff485a543a04ef9ac04c3e" @@ -46,11 +51,6 @@ "ImportPath": "github.com/jacobsa/util/lrucache", "Rev": "459ffc8a6aae5c79645c04b6b78a6a4d7b194897" }, - { - "ImportPath": "github.com/jgeewax/cli", - "Comment": "1.2.0-137-g0f30958", - "Rev": "0f30958b14cb460d9d387a88726d95318e367c21" - }, { "ImportPath": "golang.org/x/net/context", "Rev": "b71143c25f0aad5f54981684b715686d34c56d25" diff --git a/flags.go b/flags.go index 2bc6f6cf25..a360ec94c9 100644 --- a/flags.go +++ b/flags.go @@ -18,18 +18,43 @@ import ( "os" "time" + "github.com/codegangsta/cli" mountpkg "github.com/googlecloudplatform/gcsfuse/mount" - "github.com/jgeewax/cli" ) +// Set up custom help text for gcsfuse; in particular the usage section. +func init() { + cli.AppHelpTemplate = `NAME: + {{.Name}} - {{.Usage}} + +USAGE: + {{.Name}} {{if .Flags}}[global options]{{end}} bucket mountpoint + {{if .Version}} +VERSION: + {{.Version}} + {{end}}{{if len .Authors}} +AUTHOR(S): + {{range .Authors}}{{ . }}{{end}} + {{end}}{{if .Commands}} +COMMANDS: + {{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}} + {{end}}{{end}}{{if .Flags}} +GLOBAL OPTIONS: + {{range .Flags}}{{.}} + {{end}}{{end}}{{if .Copyright }} +COPYRIGHT: + {{.Copyright}} + {{end}} +` +} + func newApp() (app *cli.App) { app = &cli.App{ - Name: "gcsfuse", - Usage: "Mount a GCS bucket locally", - ArgumentUsage: "bucket mountpoint", - HideHelp: true, - HideVersion: true, - Writer: os.Stderr, + Name: "gcsfuse", + Usage: "Mount a GCS bucket locally", + HideHelp: true, + HideVersion: true, + Writer: os.Stderr, Flags: []cli.Flag{ cli.BoolFlag{ @@ -47,31 +72,27 @@ func newApp() (app *cli.App) { }, cli.IntFlag{ - Name: "dir-mode", - Value: 0755, - Usage: "Permissions bits for directories. (default: 0755)", - HideDefault: true, + Name: "dir-mode", + Value: 0755, + Usage: "Permissions bits for directories. (default: 0755)", }, cli.IntFlag{ - Name: "file-mode", - Value: 0644, - Usage: "Permission bits for files (default: 0644)", - HideDefault: true, + Name: "file-mode", + Value: 0644, + Usage: "Permission bits for files (default: 0644)", }, cli.IntFlag{ - Name: "uid", - Value: -1, - HideDefault: true, - Usage: "UID owner of all inodes.", + Name: "uid", + Value: -1, + Usage: "UID owner of all inodes.", }, cli.IntFlag{ - Name: "gid", - Value: -1, - HideDefault: true, - Usage: "GID owner of all inodes.", + Name: "gid", + Value: -1, + Usage: "GID owner of all inodes.", }, cli.BoolFlag{ @@ -85,9 +106,8 @@ func newApp() (app *cli.App) { ///////////////////////// cli.StringFlag{ - Name: "key-file", - Value: "", - HideDefault: true, + Name: "key-file", + Value: "", Usage: "Path to JSON key file for use with GCS. " + "(default: none, Google application default credentials used)", }, @@ -130,9 +150,8 @@ func newApp() (app *cli.App) { }, cli.StringFlag{ - Name: "temp-dir", - Value: "", - HideDefault: true, + Name: "temp-dir", + Value: "", Usage: "Temporary directory for local GCS object copies. " + "(default: system default, likely /tmp)", }, diff --git a/flags_test.go b/flags_test.go index d619351477..83fd71b802 100644 --- a/flags_test.go +++ b/flags_test.go @@ -21,9 +21,9 @@ import ( "testing" "time" + "github.com/codegangsta/cli" . "github.com/jacobsa/oglematchers" . "github.com/jacobsa/ogletest" - "github.com/jgeewax/cli" ) func TestFlags(t *testing.T) { RunTests(t) } diff --git a/main.go b/main.go index 84679d3d9e..a3ead6a991 100644 --- a/main.go +++ b/main.go @@ -29,10 +29,10 @@ import ( "golang.org/x/oauth2" "golang.org/x/oauth2/google" + "github.com/codegangsta/cli" "github.com/jacobsa/fuse" "github.com/jacobsa/gcloud/gcs" "github.com/jacobsa/syncutil" - "github.com/jgeewax/cli" ) //////////////////////////////////////////////////////////////////////// diff --git a/mount_test.go b/mount_test.go index dcd0698aae..97ee2d79c6 100644 --- a/mount_test.go +++ b/mount_test.go @@ -26,13 +26,13 @@ import ( "golang.org/x/net/context" + "github.com/codegangsta/cli" "github.com/jacobsa/fuse" "github.com/jacobsa/gcloud/gcs" "github.com/jacobsa/gcloud/gcs/gcsfake" "github.com/jacobsa/gcloud/gcs/gcsutil" . "github.com/jacobsa/ogletest" "github.com/jacobsa/timeutil" - "github.com/jgeewax/cli" ) func TestMount(t *testing.T) { RunTests(t) } diff --git a/vendor/github.com/jgeewax/cli/.travis.yml b/vendor/github.com/codegangsta/cli/.travis.yml similarity index 100% rename from vendor/github.com/jgeewax/cli/.travis.yml rename to vendor/github.com/codegangsta/cli/.travis.yml diff --git a/vendor/github.com/jgeewax/cli/LICENSE b/vendor/github.com/codegangsta/cli/LICENSE similarity index 100% rename from vendor/github.com/jgeewax/cli/LICENSE rename to vendor/github.com/codegangsta/cli/LICENSE diff --git a/vendor/github.com/jgeewax/cli/README.md b/vendor/github.com/codegangsta/cli/README.md similarity index 100% rename from vendor/github.com/jgeewax/cli/README.md rename to vendor/github.com/codegangsta/cli/README.md diff --git a/vendor/github.com/jgeewax/cli/app.go b/vendor/github.com/codegangsta/cli/app.go similarity index 99% rename from vendor/github.com/jgeewax/cli/app.go rename to vendor/github.com/codegangsta/cli/app.go index 349d98da14..e7caec99bd 100644 --- a/vendor/github.com/jgeewax/cli/app.go +++ b/vendor/github.com/codegangsta/cli/app.go @@ -51,8 +51,6 @@ type App struct { Email string // Writer writer to write output to Writer io.Writer - // The specific usage of arguments - ArgumentUsage string } // Tries to find out when this binary was compiled. diff --git a/vendor/github.com/jgeewax/cli/autocomplete/bash_autocomplete b/vendor/github.com/codegangsta/cli/autocomplete/bash_autocomplete similarity index 100% rename from vendor/github.com/jgeewax/cli/autocomplete/bash_autocomplete rename to vendor/github.com/codegangsta/cli/autocomplete/bash_autocomplete diff --git a/vendor/github.com/jgeewax/cli/autocomplete/zsh_autocomplete b/vendor/github.com/codegangsta/cli/autocomplete/zsh_autocomplete similarity index 100% rename from vendor/github.com/jgeewax/cli/autocomplete/zsh_autocomplete rename to vendor/github.com/codegangsta/cli/autocomplete/zsh_autocomplete diff --git a/vendor/github.com/jgeewax/cli/cli.go b/vendor/github.com/codegangsta/cli/cli.go similarity index 100% rename from vendor/github.com/jgeewax/cli/cli.go rename to vendor/github.com/codegangsta/cli/cli.go diff --git a/vendor/github.com/jgeewax/cli/command.go b/vendor/github.com/codegangsta/cli/command.go similarity index 90% rename from vendor/github.com/jgeewax/cli/command.go rename to vendor/github.com/codegangsta/cli/command.go index 212f128b94..54617afa74 100644 --- a/vendor/github.com/jgeewax/cli/command.go +++ b/vendor/github.com/codegangsta/cli/command.go @@ -36,11 +36,21 @@ type Command struct { SkipFlagParsing bool // Boolean to hide built-in help command HideHelp bool + + commandNamePath []string +} + +// Returns the full name of the command. +// For subcommands this ensures that parent commands are part of the command path +func (c Command) FullName() string { + if c.commandNamePath == nil { + return c.Name + } + return strings.Join(c.commandNamePath, " ") } // Invokes the command given the context, parses ctx.Args() to generate command-specific flags func (c Command) Run(ctx *Context) error { - if len(c.Subcommands) > 0 || c.Before != nil || c.After != nil { return c.startApp(ctx) } @@ -179,5 +189,12 @@ func (c Command) startApp(ctx *Context) error { app.Action = helpSubcommand.Action } + var newCmds []Command + for _, cc := range app.Commands { + cc.commandNamePath = []string{c.Name, cc.Name} + newCmds = append(newCmds, cc) + } + app.Commands = newCmds + return app.RunAsSubcommand(ctx) } diff --git a/vendor/github.com/jgeewax/cli/context.go b/vendor/github.com/codegangsta/cli/context.go similarity index 100% rename from vendor/github.com/jgeewax/cli/context.go rename to vendor/github.com/codegangsta/cli/context.go diff --git a/vendor/github.com/jgeewax/cli/flag.go b/vendor/github.com/codegangsta/cli/flag.go similarity index 89% rename from vendor/github.com/jgeewax/cli/flag.go rename to vendor/github.com/codegangsta/cli/flag.go index d6337eac23..531b09130f 100644 --- a/vendor/github.com/jgeewax/cli/flag.go +++ b/vendor/github.com/codegangsta/cli/flag.go @@ -67,18 +67,13 @@ type GenericFlag struct { Value Generic Usage string EnvVar string - HideDefault bool } // String returns the string representation of the generic flag to display the // help text to the user (uses the String() method of the generic flag to show // the value) func (f GenericFlag) String() string { - if f.HideDefault { - return withEnvHint(f.EnvVar, fmt.Sprintf("%s%s\t%v", prefixFor(f.Name), f.Name, f.Usage)) - } else { - return withEnvHint(f.EnvVar, fmt.Sprintf("%s%s \t%v (default: \"%v\")", prefixFor(f.Name), f.Name, f.Usage, f.Value)) - } + return withEnvHint(f.EnvVar, fmt.Sprintf("%s%s \"%v\"\t%v", prefixFor(f.Name), f.Name, f.Value, f.Usage)) } // Apply takes the flagset and calls Set on the generic flag with the value @@ -321,16 +316,20 @@ type StringFlag struct { Value string Usage string EnvVar string - HideDefault bool } // String returns the usage func (f StringFlag) String() string { - if f.HideDefault { - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \t%v", prefixedNames(f.Name), f.Usage)) + var fmtString string + fmtString = "%s %v\t%v" + + if len(f.Value) > 0 { + fmtString = "%s \"%v\"\t%v" } else { - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \t%v (default: \"%v\")", prefixedNames(f.Name), f.Usage, f.Value)) + fmtString = "%s %v\t%v" } + + return withEnvHint(f.EnvVar, fmt.Sprintf(fmtString, prefixedNames(f.Name), f.Value, f.Usage)) } // Apply populates the flag given the flag set and environment @@ -361,16 +360,11 @@ type IntFlag struct { Value int Usage string EnvVar string - HideDefault bool } // String returns the usage func (f IntFlag) String() string { - if f.HideDefault { - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \t%v", prefixedNames(f.Name), f.Usage)) - } else { - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \t%v (default: %v)", prefixedNames(f.Name), f.Usage, f.Value)) - } + return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage)) } // Apply populates the flag given the flag set and environment @@ -404,16 +398,11 @@ type DurationFlag struct { Value time.Duration Usage string EnvVar string - HideDefault bool } // String returns a readable representation of this value (for usage defaults) func (f DurationFlag) String() string { - if f.HideDefault { - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \t%v", prefixedNames(f.Name), f.Usage)) - } else { - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \t%v (default: \"%v\")", prefixedNames(f.Name), f.Usage, f.Value)) - } + return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage)) } // Apply populates the flag given the flag set and environment @@ -447,16 +436,11 @@ type Float64Flag struct { Value float64 Usage string EnvVar string - HideDefault bool } // String returns the usage func (f Float64Flag) String() string { - if f.HideDefault { - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \t%v", prefixedNames(f.Name), f.Usage)) - } else { - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \t%v (default: %v)", prefixedNames(f.Name), f.Usage, f.Value)) - } + return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage)) } // Apply populates the flag given the flag set and environment diff --git a/vendor/github.com/jgeewax/cli/help.go b/vendor/github.com/codegangsta/cli/help.go similarity index 95% rename from vendor/github.com/jgeewax/cli/help.go rename to vendor/github.com/codegangsta/cli/help.go index 3bfd316ae8..66ef2fb781 100644 --- a/vendor/github.com/jgeewax/cli/help.go +++ b/vendor/github.com/codegangsta/cli/help.go @@ -15,7 +15,7 @@ var AppHelpTemplate = `NAME: {{.Name}} - {{.Usage}} USAGE: - {{.Name}} {{if .Flags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgumentUsage}}{{.ArgumentUsage}}{{else}}[arguments...]{{end}} + {{.Name}} {{if .Flags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} [arguments...] {{if .Version}} VERSION: {{.Version}} @@ -38,10 +38,10 @@ COPYRIGHT: // cli.go uses text/template to render templates. You can // render custom help text by setting this variable. var CommandHelpTemplate = `NAME: - {{.Name}} - {{.Usage}} + {{.FullName}} - {{.Usage}} USAGE: - command {{.Name}}{{if .Flags}} [command options]{{end}} [arguments...]{{if .Description}} + command {{.FullName}}{{if .Flags}} [command options]{{end}} [arguments...]{{if .Description}} DESCRIPTION: {{.Description}}{{end}}{{if .Flags}}