Merge pull request #408 from harshavardhana/pr_out_update_cli_with_new_changes

master
Harshavardhana 10 years ago
commit 4c6677fd2c
  1. 4
      Godeps/Godeps.json
  2. 14
      Godeps/_workspace/src/github.com/minio-io/cli/README.md
  3. 6
      Godeps/_workspace/src/github.com/minio-io/cli/command.go
  4. 1
      Godeps/_workspace/src/github.com/minio-io/cli/flag.go
  5. 20
      Godeps/_workspace/src/github.com/minio-io/cli/help.go

4
Godeps/Godeps.json generated vendored

@ -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",

@ -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() {

@ -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()

@ -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.

@ -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
}

Loading…
Cancel
Save