mirror of
https://github.com/minio/minio.git
synced 2025-01-12 15:33:22 -05:00
Update cli with new changes
This commit is contained in:
parent
c728798137
commit
5defd8ffdd
4
Godeps/Godeps.json
generated
4
Godeps/Godeps.json
generated
@ -15,8 +15,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/minio-io/cli",
|
"ImportPath": "github.com/minio-io/cli",
|
||||||
"Comment": "1.2.0-96-gfcc23e2",
|
"Comment": "1.2.0-99-g1ee5c11",
|
||||||
"Rev": "fcc23e23a705c0d95fce2a446c364ac31a1c73a5"
|
"Rev": "1ee5c115af7856a16f133e2f2d3d9f91895c2ddb"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/minio-io/iodine",
|
"ImportPath": "github.com/minio-io/iodine",
|
||||||
|
14
Godeps/_workspace/src/github.com/minio-io/cli/README.md
generated
vendored
14
Godeps/_workspace/src/github.com/minio-io/cli/README.md
generated
vendored
@ -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
|
||||||
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:
|
You can view the API docs here:
|
||||||
http://godoc.org/github.com/codegangsta/cli
|
http://godoc.org/github.com/minio-io/cli
|
||||||
|
|
||||||
## Overview
|
## 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.
|
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:
|
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:
|
Make sure your `PATH` includes to the `$GOPATH/bin` directory so your commands can be easily used:
|
||||||
@ -32,7 +30,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/minio-io/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -47,7 +45,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/minio-io/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -75,7 +73,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/minio-io/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
6
Godeps/_workspace/src/github.com/minio-io/cli/command.go
generated
vendored
6
Godeps/_workspace/src/github.com/minio-io/cli/command.go
generated
vendored
@ -36,6 +36,8 @@ type Command struct {
|
|||||||
SkipFlagParsing bool
|
SkipFlagParsing bool
|
||||||
// Boolean to hide built-in help command
|
// Boolean to hide built-in help command
|
||||||
HideHelp bool
|
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
|
// 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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Command) isNotHidden() bool {
|
||||||
|
return !c.Hide
|
||||||
|
}
|
||||||
|
|
||||||
func (c Command) startApp(ctx *Context) error {
|
func (c Command) startApp(ctx *Context) error {
|
||||||
app := NewApp()
|
app := NewApp()
|
||||||
|
|
||||||
|
1
Godeps/_workspace/src/github.com/minio-io/cli/flag.go
generated
vendored
1
Godeps/_workspace/src/github.com/minio-io/cli/flag.go
generated
vendored
@ -27,6 +27,7 @@ var VersionFlag = BoolFlag{
|
|||||||
var HelpFlag = BoolFlag{
|
var HelpFlag = BoolFlag{
|
||||||
Name: "help, h",
|
Name: "help, h",
|
||||||
Usage: "show help",
|
Usage: "show help",
|
||||||
|
Hide: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flag is a common interface related to parsing flags in cli.
|
// Flag is a common interface related to parsing flags in cli.
|
||||||
|
20
Godeps/_workspace/src/github.com/minio-io/cli/help.go
generated
vendored
20
Godeps/_workspace/src/github.com/minio-io/cli/help.go
generated
vendored
@ -71,6 +71,7 @@ var helpCommand = Command{
|
|||||||
ShowAppHelp(c)
|
ShowAppHelp(c)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Hide: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
var helpSubcommand = Command{
|
var helpSubcommand = Command{
|
||||||
@ -85,6 +86,7 @@ var helpSubcommand = Command{
|
|||||||
ShowSubcommandHelp(c)
|
ShowSubcommandHelp(c)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Hide: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints help for the App
|
// Prints help for the App
|
||||||
@ -99,19 +101,27 @@ func ShowAppHelp(c *Context) {
|
|||||||
// Make a copy of c.App context
|
// Make a copy of c.App context
|
||||||
app := *c.App
|
app := *c.App
|
||||||
app.Flags = make([]Flag, 0)
|
app.Flags = make([]Flag, 0)
|
||||||
|
app.Commands = make([]Command, 0)
|
||||||
for _, flag := range c.App.Flags {
|
for _, flag := range c.App.Flags {
|
||||||
if flag.isNotHidden() {
|
if flag.isNotHidden() {
|
||||||
app.Flags = append(app.Flags, flag)
|
app.Flags = append(app.Flags, flag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, command := range c.App.Commands {
|
||||||
|
if command.isNotHidden() {
|
||||||
|
app.Commands = append(app.Commands, command)
|
||||||
|
}
|
||||||
|
}
|
||||||
HelpPrinter(AppHelpTemplate, app)
|
HelpPrinter(AppHelpTemplate, app)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints the list of subcommands as the default app completion method
|
// Prints the list of subcommands as the default app completion method
|
||||||
func DefaultAppComplete(c *Context) {
|
func DefaultAppComplete(c *Context) {
|
||||||
for _, command := range c.App.Commands {
|
for _, command := range c.App.Commands {
|
||||||
for _, name := range command.Names() {
|
if command.isNotHidden() {
|
||||||
fmt.Fprintln(c.App.Writer, name)
|
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
|
// Make a copy of c.App context
|
||||||
app := *c.App
|
app := *c.App
|
||||||
app.Flags = make([]Flag, 0)
|
app.Flags = make([]Flag, 0)
|
||||||
|
app.Commands = make([]Command, 0)
|
||||||
for _, flag := range c.App.Flags {
|
for _, flag := range c.App.Flags {
|
||||||
if flag.isNotHidden() {
|
if flag.isNotHidden() {
|
||||||
app.Flags = append(app.Flags, flag)
|
app.Flags = append(app.Flags, flag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, command := range c.App.Commands {
|
||||||
|
if command.isNotHidden() {
|
||||||
|
app.Commands = append(app.Commands, command)
|
||||||
|
}
|
||||||
|
}
|
||||||
HelpPrinter(SubcommandHelpTemplate, app)
|
HelpPrinter(SubcommandHelpTemplate, app)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user