From 5defd8ffdd46817c8831ed283d0e61c229ec63e3 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 29 Mar 2015 13:38:30 -0700 Subject: [PATCH] Update cli with new changes --- Godeps/Godeps.json | 4 ++-- .../src/github.com/minio-io/cli/README.md | 14 ++++++------- .../src/github.com/minio-io/cli/command.go | 6 ++++++ .../src/github.com/minio-io/cli/flag.go | 1 + .../src/github.com/minio-io/cli/help.go | 20 +++++++++++++++++-- 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index a5626b406..529813892 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -15,8 +15,8 @@ }, { "ImportPath": "github.com/minio-io/cli", - "Comment": "1.2.0-96-gfcc23e2", - "Rev": "fcc23e23a705c0d95fce2a446c364ac31a1c73a5" + "Comment": "1.2.0-99-g1ee5c11", + "Rev": "1ee5c115af7856a16f133e2f2d3d9f91895c2ddb" }, { "ImportPath": "github.com/minio-io/iodine", diff --git a/Godeps/_workspace/src/github.com/minio-io/cli/README.md b/Godeps/_workspace/src/github.com/minio-io/cli/README.md index 4b3ddb0a3..450919513 100644 --- a/Godeps/_workspace/src/github.com/minio-io/cli/README.md +++ b/Godeps/_workspace/src/github.com/minio-io/cli/README.md @@ -1,10 +1,8 @@ -[![Build Status](https://travis-ci.org/codegangsta/cli.png?branch=master)](https://travis-ci.org/codegangsta/cli) - # cli.go -cli.go is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way. +cli.go is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way. - This is a fork of ``github.com/codegangsta/cli`` until our patches get merge upstream You can view the API docs here: -http://godoc.org/github.com/codegangsta/cli +http://godoc.org/github.com/minio-io/cli ## Overview Command line apps are usually so tiny that there is absolutely no reason why your code should *not* be self-documenting. Things like generating help text and parsing command flags/options should not hinder productivity when writing a command line app. @@ -16,7 +14,7 @@ Make sure you have a working Go environment (go 1.1 is *required*). [See the ins To install `cli.go`, simply run: ``` -$ go get github.com/codegangsta/cli +$ go get github.com/minio-io/cli ``` Make sure your `PATH` includes to the `$GOPATH/bin` directory so your commands can be easily used: @@ -32,7 +30,7 @@ package main import ( "os" - "github.com/codegangsta/cli" + "github.com/minio-io/cli" ) func main() { @@ -47,7 +45,7 @@ package main import ( "os" - "github.com/codegangsta/cli" + "github.com/minio-io/cli" ) func main() { @@ -75,7 +73,7 @@ package main import ( "os" - "github.com/codegangsta/cli" + "github.com/minio-io/cli" ) func main() { diff --git a/Godeps/_workspace/src/github.com/minio-io/cli/command.go b/Godeps/_workspace/src/github.com/minio-io/cli/command.go index b61691c86..ec857b0be 100644 --- a/Godeps/_workspace/src/github.com/minio-io/cli/command.go +++ b/Godeps/_workspace/src/github.com/minio-io/cli/command.go @@ -36,6 +36,8 @@ type Command struct { SkipFlagParsing bool // Boolean to hide built-in help command HideHelp bool + // Boolean to hide this command from help or completion + Hide bool } // Invokes the command given the context, parses ctx.Args() to generate command-specific flags @@ -139,6 +141,10 @@ func (c Command) HasName(name string) bool { return false } +func (c Command) isNotHidden() bool { + return !c.Hide +} + func (c Command) startApp(ctx *Context) error { app := NewApp() diff --git a/Godeps/_workspace/src/github.com/minio-io/cli/flag.go b/Godeps/_workspace/src/github.com/minio-io/cli/flag.go index 2d4e25ce6..0dbbc689b 100644 --- a/Godeps/_workspace/src/github.com/minio-io/cli/flag.go +++ b/Godeps/_workspace/src/github.com/minio-io/cli/flag.go @@ -27,6 +27,7 @@ var VersionFlag = BoolFlag{ var HelpFlag = BoolFlag{ Name: "help, h", Usage: "show help", + Hide: true, } // Flag is a common interface related to parsing flags in cli. diff --git a/Godeps/_workspace/src/github.com/minio-io/cli/help.go b/Godeps/_workspace/src/github.com/minio-io/cli/help.go index 7a250d5eb..a6083fcb1 100644 --- a/Godeps/_workspace/src/github.com/minio-io/cli/help.go +++ b/Godeps/_workspace/src/github.com/minio-io/cli/help.go @@ -71,6 +71,7 @@ var helpCommand = Command{ ShowAppHelp(c) } }, + Hide: true, } var helpSubcommand = Command{ @@ -85,6 +86,7 @@ var helpSubcommand = Command{ ShowSubcommandHelp(c) } }, + Hide: true, } // Prints help for the App @@ -99,19 +101,27 @@ func ShowAppHelp(c *Context) { // Make a copy of c.App context app := *c.App app.Flags = make([]Flag, 0) + app.Commands = make([]Command, 0) for _, flag := range c.App.Flags { if flag.isNotHidden() { app.Flags = append(app.Flags, flag) } } + for _, command := range c.App.Commands { + if command.isNotHidden() { + app.Commands = append(app.Commands, command) + } + } HelpPrinter(AppHelpTemplate, app) } // Prints the list of subcommands as the default app completion method func DefaultAppComplete(c *Context) { for _, command := range c.App.Commands { - for _, name := range command.Names() { - fmt.Fprintln(c.App.Writer, name) + if command.isNotHidden() { + for _, name := range command.Names() { + fmt.Fprintln(c.App.Writer, name) + } } } } @@ -123,11 +133,17 @@ func ShowCommandHelp(c *Context, command string) { // Make a copy of c.App context app := *c.App app.Flags = make([]Flag, 0) + app.Commands = make([]Command, 0) for _, flag := range c.App.Flags { if flag.isNotHidden() { app.Flags = append(app.Flags, flag) } } + for _, command := range c.App.Commands { + if command.isNotHidden() { + app.Commands = append(app.Commands, command) + } + } HelpPrinter(SubcommandHelpTemplate, app) return }