add String method to command
This commit is contained in:
parent
5077683b70
commit
7aa92fa8b5
14
cmd/cmd.go
14
cmd/cmd.go
@ -1,4 +1,4 @@
|
|||||||
// Package cmd is an interface for parsing the command line
|
// Package cmd is an interface for building a command line binary
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -87,13 +87,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Cmd interface {
|
type Cmd interface {
|
||||||
|
// Init parses the command line args
|
||||||
|
// TODO: replace with Run method
|
||||||
|
Init(opts ...Option) error
|
||||||
// The cli app within this cmd
|
// The cli app within this cmd
|
||||||
App() *cli.App
|
App() *cli.App
|
||||||
// Adds options, parses flags and initialise
|
|
||||||
// exits on error
|
|
||||||
Init(opts ...Option) error
|
|
||||||
// Options set within this command
|
// Options set within this command
|
||||||
Options() Options
|
Options() Options
|
||||||
|
// Implementation
|
||||||
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type cmd struct {
|
type cmd struct {
|
||||||
@ -902,6 +904,10 @@ func (c *cmd) Init(opts ...Option) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *cmd) String() string {
|
||||||
|
return "micro/cli"
|
||||||
|
}
|
||||||
|
|
||||||
func App() *cli.App {
|
func App() *cli.App {
|
||||||
return DefaultCmd.App()
|
return DefaultCmd.App()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user