|
|
|
@ -146,7 +146,7 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
cli.NewApp().Run(os.Args)
|
|
|
|
|
(&cli.App{}).Run(os.Args)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -167,12 +167,13 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
app.Name = "boom"
|
|
|
|
|
app.Usage = "make an explosive entrance"
|
|
|
|
|
app.Action = func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("boom! I say!")
|
|
|
|
|
return nil
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Name: "boom",
|
|
|
|
|
Usage: "make an explosive entrance",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("boom! I say!")
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
@ -205,12 +206,13 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
app.Name = "greet"
|
|
|
|
|
app.Usage = "fight the loneliness!"
|
|
|
|
|
app.Action = func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("Hello friend!")
|
|
|
|
|
return nil
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Name: "greet",
|
|
|
|
|
Usage: "fight the loneliness!",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("Hello friend!")
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
@ -268,11 +270,11 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
|
|
app.Action = func(c *cli.Context) error {
|
|
|
|
|
fmt.Printf("Hello %q", c.Args().Get(0))
|
|
|
|
|
return nil
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Printf("Hello %q", c.Args().Get(0))
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
@ -297,27 +299,26 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
|
|
app.Flags = []cli.Flag {
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "lang",
|
|
|
|
|
Value: "english",
|
|
|
|
|
Usage: "language for the greeting",
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Flags: []cli.Flag {
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "lang",
|
|
|
|
|
Value: "english",
|
|
|
|
|
Usage: "language for the greeting",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
name := "Nefertiti"
|
|
|
|
|
if c.NArg() > 0 {
|
|
|
|
|
name = c.Args().Get(0)
|
|
|
|
|
}
|
|
|
|
|
if c.String("lang") == "spanish" {
|
|
|
|
|
fmt.Println("Hola", name)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("Hello", name)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Action = func(c *cli.Context) error {
|
|
|
|
|
name := "Nefertiti"
|
|
|
|
|
if c.NArg() > 0 {
|
|
|
|
|
name = c.Args().Get(0)
|
|
|
|
|
}
|
|
|
|
|
if c.String("lang") == "spanish" {
|
|
|
|
|
fmt.Println("Hola", name)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("Hello", name)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
@ -343,28 +344,27 @@ import (
|
|
|
|
|
func main() {
|
|
|
|
|
var language string
|
|
|
|
|
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
|
|
app.Flags = []cli.Flag {
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "lang",
|
|
|
|
|
Value: "english",
|
|
|
|
|
Usage: "language for the greeting",
|
|
|
|
|
Destination: &language,
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Flags: []cli.Flag {
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "lang",
|
|
|
|
|
Value: "english",
|
|
|
|
|
Usage: "language for the greeting",
|
|
|
|
|
Destination: &language,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
name := "someone"
|
|
|
|
|
if c.NArg() > 0 {
|
|
|
|
|
name = c.Args().Get(0)
|
|
|
|
|
}
|
|
|
|
|
if language == "spanish" {
|
|
|
|
|
fmt.Println("Hola", name)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("Hello", name)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Action = func(c *cli.Context) error {
|
|
|
|
|
name := "someone"
|
|
|
|
|
if c.NArg() > 0 {
|
|
|
|
|
name = c.Args().Get(0)
|
|
|
|
|
}
|
|
|
|
|
if language == "spanish" {
|
|
|
|
|
fmt.Println("Hola", name)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("Hello", name)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
@ -394,13 +394,13 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "config",
|
|
|
|
|
Aliases: []string{"c"},
|
|
|
|
|
Usage: "Load configuration from `FILE`",
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "config",
|
|
|
|
|
Aliases: []string{"c"},
|
|
|
|
|
Usage: "Load configuration from `FILE`",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -436,14 +436,14 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
|
|
app.Flags = []cli.Flag {
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "lang",
|
|
|
|
|
Aliases: []string{"l"},
|
|
|
|
|
Value: "english",
|
|
|
|
|
Usage: "language for the greeting",
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Flags: []cli.Flag {
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "lang",
|
|
|
|
|
Aliases: []string{"l"},
|
|
|
|
|
Value: "english",
|
|
|
|
|
Usage: "language for the greeting",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -473,15 +473,15 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
|
|
app.Flags = []cli.Flag {
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "lang",
|
|
|
|
|
Aliases: []string{"l"},
|
|
|
|
|
Value: "english",
|
|
|
|
|
Usage: "language for the greeting",
|
|
|
|
|
EnvVars: []string{"APP_LANG"},
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Flags: []cli.Flag {
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "lang",
|
|
|
|
|
Aliases: []string{"l"},
|
|
|
|
|
Value: "english",
|
|
|
|
|
Usage: "language for the greeting",
|
|
|
|
|
EnvVars: []string{"APP_LANG"},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -506,15 +506,15 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "lang",
|
|
|
|
|
Aliases: []string{"l"},
|
|
|
|
|
Value: "english",
|
|
|
|
|
Usage: "language for the greeting",
|
|
|
|
|
EnvVars: []string{"LEGACY_COMPAT_LANG", "APP_LANG", "LANG"},
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
&cli.StringFlag{
|
|
|
|
|
Name: "lang",
|
|
|
|
|
Aliases: []string{"l"},
|
|
|
|
|
Value: "english",
|
|
|
|
|
Usage: "language for the greeting",
|
|
|
|
|
EnvVars: []string{"LEGACY_COMPAT_LANG", "APP_LANG", "LANG"},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -569,21 +569,20 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
|
|
flags := []cli.Flag{
|
|
|
|
|
altsrc.NewIntFlag(&cli.IntFlag{Name: "test"}),
|
|
|
|
|
&cli.StringFlag{Name: "load"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Action = func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("yaml ist rad")
|
|
|
|
|
return nil
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("yaml ist rad")
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
Before: altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc("load")),
|
|
|
|
|
Flags: flags,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Before = altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc("load"))
|
|
|
|
|
app.Flags = flags
|
|
|
|
|
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
@ -607,46 +606,46 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
|
|
app.Commands = []*cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "add",
|
|
|
|
|
Aliases: []string{"a"},
|
|
|
|
|
Usage: "add a task to the list",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("added task: ", c.Args().First())
|
|
|
|
|
return nil
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Commands: []*cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "add",
|
|
|
|
|
Aliases: []string{"a"},
|
|
|
|
|
Usage: "add a task to the list",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("added task: ", c.Args().First())
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "complete",
|
|
|
|
|
Aliases: []string{"c"},
|
|
|
|
|
Usage: "complete a task on the list",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("completed task: ", c.Args().First())
|
|
|
|
|
return nil
|
|
|
|
|
{
|
|
|
|
|
Name: "complete",
|
|
|
|
|
Aliases: []string{"c"},
|
|
|
|
|
Usage: "complete a task on the list",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("completed task: ", c.Args().First())
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "template",
|
|
|
|
|
Aliases: []string{"t"},
|
|
|
|
|
Usage: "options for task templates",
|
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "add",
|
|
|
|
|
Usage: "add a new template",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("new task template: ", c.Args().First())
|
|
|
|
|
return nil
|
|
|
|
|
{
|
|
|
|
|
Name: "template",
|
|
|
|
|
Aliases: []string{"t"},
|
|
|
|
|
Usage: "options for task templates",
|
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "add",
|
|
|
|
|
Usage: "add a new template",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("new task template: ", c.Args().First())
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "remove",
|
|
|
|
|
Usage: "remove an existing template",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("removed task template: ", c.Args().First())
|
|
|
|
|
return nil
|
|
|
|
|
{
|
|
|
|
|
Name: "remove",
|
|
|
|
|
Usage: "remove an existing template",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("removed task template: ", c.Args().First())
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -675,19 +674,19 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
|
|
app.Commands = []*cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "noop",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "add",
|
|
|
|
|
Category: "template",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "remove",
|
|
|
|
|
Category: "template",
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Commands: []*cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "noop",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "add",
|
|
|
|
|
Category: "template",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "remove",
|
|
|
|
|
Category: "template",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -723,19 +722,20 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
|
&cli.BoolFlag{
|
|
|
|
|
Name: "ginger-crouton",
|
|
|
|
|
Value: true,
|
|
|
|
|
Usage: "is it in the soup?",
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
&cli.BoolFlag{
|
|
|
|
|
Name: "ginger-crouton",
|
|
|
|
|
Value: true,
|
|
|
|
|
Usage: "is it in the soup?",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
Action: func(ctx *cli.Context) error {
|
|
|
|
|
if !ctx.Bool("ginger-crouton") {
|
|
|
|
|
return cli.Exit("it is not in the soup", 86)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
app.Action = func(ctx *cli.Context) error {
|
|
|
|
|
if !ctx.Bool("ginger-crouton") {
|
|
|
|
|
return cli.Exit("it is not in the soup", 86)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
@ -766,25 +766,26 @@ import (
|
|
|
|
|
func main() {
|
|
|
|
|
tasks := []string{"cook", "clean", "laundry", "eat", "sleep", "code"}
|
|
|
|
|
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
app.EnableBashCompletion = true
|
|
|
|
|
app.Commands = []*cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "complete",
|
|
|
|
|
Aliases: []string{"c"},
|
|
|
|
|
Usage: "complete a task on the list",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("completed task: ", c.Args().First())
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
BashComplete: func(c *cli.Context) {
|
|
|
|
|
// This will complete if no args are passed
|
|
|
|
|
if c.NArg() > 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
for _, t := range tasks {
|
|
|
|
|
fmt.Println(t)
|
|
|
|
|
}
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
EnableBashCompletion: true,
|
|
|
|
|
Commands: []*cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "complete",
|
|
|
|
|
Aliases: []string{"c"},
|
|
|
|
|
Usage: "complete a task on the list",
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
fmt.Println("completed task: ", c.Args().First())
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
BashComplete: func(c *cli.Context) {
|
|
|
|
|
// This will complete if no args are passed
|
|
|
|
|
if c.NArg() > 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
for _, t := range tasks {
|
|
|
|
|
fmt.Println(t)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
@ -840,11 +841,12 @@ func main() {
|
|
|
|
|
Hidden: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
app.EnableBashCompletion = true
|
|
|
|
|
app.Commands = []*cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "wat",
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
EnableBashCompletion: true,
|
|
|
|
|
Commands: []*cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "wat",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
@ -919,7 +921,7 @@ VERSION:
|
|
|
|
|
fmt.Println("Ha HA. I pwnd the help!!1")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cli.NewApp().Run(os.Args)
|
|
|
|
|
(&cli.App{}).Run(os.Args)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -946,7 +948,7 @@ func main() {
|
|
|
|
|
EnvVars: []string{"SHOW_HALP", "HALPPLZ"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cli.NewApp().Run(os.Args)
|
|
|
|
|
(&cli.App{}).Run(os.Args)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -980,9 +982,10 @@ func main() {
|
|
|
|
|
Usage: "print only the version",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
app.Name = "partay"
|
|
|
|
|
app.Version = "v19.99.0"
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Name: "partay",
|
|
|
|
|
Version: "v19.99.0",
|
|
|
|
|
}
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
@ -1012,9 +1015,10 @@ func main() {
|
|
|
|
|
fmt.Printf("version=%s revision=%s\n", c.App.Version, Revision)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
app.Name = "partay"
|
|
|
|
|
app.Version = "v19.99.0"
|
|
|
|
|
app := &cli.App{
|
|
|
|
|
Name: "partay",
|
|
|
|
|
Version: "v19.99.0",
|
|
|
|
|
}
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
@ -1091,183 +1095,189 @@ func (g *genericType) String() string {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
app.Name = "kənˈtrīv"
|
|
|
|
|
app.Version = "v19.99.0"
|
|
|
|
|
app.Compiled = time.Now()
|
|
|
|
|
app.Authors = []*cli.Author{
|
|
|
|
|
&cli.Author{
|
|
|
|
|
Name: "Example Human",
|
|
|
|
|
Email: "human@example.com",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
app.Copyright = "(c) 1999 Serious Enterprise"
|
|
|
|
|
app.HelpName = "contrive"
|
|
|
|
|
app.Usage = "demonstrate available API"
|
|
|
|
|
app.UsageText = "contrive - demonstrating the available API"
|
|
|
|
|
app.ArgsUsage = "[args and such]"
|
|
|
|
|
app.Commands = []*cli.Command{
|
|
|
|
|
&cli.Command{
|
|
|
|
|
Name: "doo",
|
|
|
|
|
Aliases: []string{"do"},
|
|
|
|
|
Category: "motion",
|
|
|
|
|
Usage: "do the doo",
|
|
|
|
|
UsageText: "doo - does the dooing",
|
|
|
|
|
Description: "no really, there is a lot of dooing to be done",
|
|
|
|
|
ArgsUsage: "[arrgh]",
|
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
&cli.BoolFlag{Name: "forever", Aliases: []string{"forevvarr"}},
|
|
|
|
|
app := cli.App{
|
|
|
|
|
Name: "kənˈtrīv",
|
|
|
|
|
Version: "v19.99.0",
|
|
|
|
|
Compiled: time.Now(),
|
|
|
|
|
Authors: []*cli.Author{
|
|
|
|
|
&cli.Author{
|
|
|
|
|
Name: "Example Human",
|
|
|
|
|
Email: "human@example.com",
|
|
|
|
|
},
|
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
|
&cli.Command{
|
|
|
|
|
Name: "wop",
|
|
|
|
|
Action: wopAction,
|
|
|
|
|
},
|
|
|
|
|
Copyright: "(c) 1999 Serious Enterprise",
|
|
|
|
|
HelpName: "contrive",
|
|
|
|
|
Usage: "demonstrate available API",
|
|
|
|
|
UsageText: "contrive - demonstrating the available API",
|
|
|
|
|
ArgsUsage: "[args and such]",
|
|
|
|
|
Commands: []*cli.Command{
|
|
|
|
|
&cli.Command{
|
|
|
|
|
Name: "doo",
|
|
|
|
|
Aliases: []string{"do"},
|
|
|
|
|
Category: "motion",
|
|
|
|
|
Usage: "do the doo",
|
|
|
|
|
UsageText: "doo - does the dooing",
|
|
|
|
|
Description: "no really, there is a lot of dooing to be done",
|
|
|
|
|
ArgsUsage: "[arrgh]",
|
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
&cli.BoolFlag{Name: "forever", Aliases: []string{"forevvarr"}},
|
|
|
|
|
},
|
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
|
&cli.Command{
|
|
|
|
|
Name: "wop",
|
|
|
|
|
Action: wopAction,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
SkipFlagParsing: false,
|
|
|
|
|
HideHelp: false,
|
|
|
|
|
Hidden: false,
|
|
|
|
|
HelpName: "doo!",
|
|
|
|
|
BashComplete: func(c *cli.Context) {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "--better\n")
|
|
|
|
|
},
|
|
|
|
|
Before: func(c *cli.Context) error {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "brace for impact\n")
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
After: func(c *cli.Context) error {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "did we lose anyone?\n")
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
c.Command.FullName()
|
|
|
|
|
c.Command.HasName("wop")
|
|
|
|
|
c.Command.Names()
|
|
|
|
|
c.Command.VisibleFlags()
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "dodododododoodododddooooododododooo\n")
|
|
|
|
|
if c.Bool("forever") {
|
|
|
|
|
c.Command.Run(c)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "for shame\n")
|
|
|
|
|
return err
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
SkipFlagParsing: false,
|
|
|
|
|
HideHelp: false,
|
|
|
|
|
Hidden: false,
|
|
|
|
|
HelpName: "doo!",
|
|
|
|
|
BashComplete: func(c *cli.Context) {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "--better\n")
|
|
|
|
|
},
|
|
|
|
|
Before: func(c *cli.Context) error {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "brace for impact\n")
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
After: func(c *cli.Context) error {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "did we lose anyone?\n")
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
c.Command.FullName()
|
|
|
|
|
c.Command.HasName("wop")
|
|
|
|
|
c.Command.Names()
|
|
|
|
|
c.Command.VisibleFlags()
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "dodododododoodododddooooododododooo\n")
|
|
|
|
|
if c.Bool("forever") {
|
|
|
|
|
c.Command.Run(c)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "for shame\n")
|
|
|
|
|
return err
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
|
&cli.BoolFlag{Name: "fancy"},
|
|
|
|
|
&cli.BoolFlag{Value: true, Name: "fancier"},
|
|
|
|
|
&cli.DurationFlag{Name: "howlong", Aliases: []string{"H"}, Value: time.Second * 3},
|
|
|
|
|
&cli.Float64Flag{Name: "howmuch"},
|
|
|
|
|
&cli.GenericFlag{Name: "wat", Value: &genericType{}},
|
|
|
|
|
&cli.Int64Flag{Name: "longdistance"},
|
|
|
|
|
&cli.Int64SliceFlag{Name: "intervals"},
|
|
|
|
|
&cli.IntFlag{Name: "distance"},
|
|
|
|
|
&cli.IntSliceFlag{Name: "times"},
|
|
|
|
|
&cli.StringFlag{Name: "dance-move", Aliases: []string{"d"}},
|
|
|
|
|
&cli.StringSliceFlag{Name: "names", Aliases: []string{"N"}},
|
|
|
|
|
&cli.UintFlag{Name: "age"},
|
|
|
|
|
&cli.Uint64Flag{Name: "bigage"},
|
|
|
|
|
}
|
|
|
|
|
app.EnableBashCompletion = true
|
|
|
|
|
app.HideHelp = false
|
|
|
|
|
app.HideVersion = false
|
|
|
|
|
app.BashComplete = func(c *cli.Context) {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "lipstick\nkiss\nme\nlipstick\nringo\n")
|
|
|
|
|
}
|
|
|
|
|
app.Before = func(c *cli.Context) error {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "HEEEERE GOES\n")
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
app.After = func(c *cli.Context) error {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "Phew!\n")
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
app.CommandNotFound = func(c *cli.Context, command string) {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "Thar be no %q here.\n", command)
|
|
|
|
|
}
|
|
|
|
|
app.OnUsageError = func(c *cli.Context, err error, isSubcommand bool) error {
|
|
|
|
|
if isSubcommand {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
&cli.BoolFlag{Name: "fancy"},
|
|
|
|
|
&cli.BoolFlag{Value: true, Name: "fancier"},
|
|
|
|
|
&cli.DurationFlag{Name: "howlong", Aliases: []string{"H"}, Value: time.Second * 3},
|
|
|
|
|
&cli.Float64Flag{Name: "howmuch"},
|
|
|
|
|
&cli.GenericFlag{Name: "wat", Value: &genericType{}},
|
|
|
|
|
&cli.Int64Flag{Name: "longdistance"},
|
|
|
|
|
&cli.Int64SliceFlag{Name: "intervals"},
|
|
|
|
|
&cli.IntFlag{Name: "distance"},
|
|
|
|
|
&cli.IntSliceFlag{Name: "times"},
|
|
|
|
|
&cli.StringFlag{Name: "dance-move", Aliases: []string{"d"}},
|
|
|
|
|
&cli.StringSliceFlag{Name: "names", Aliases: []string{"N"}},
|
|
|
|
|
&cli.UintFlag{Name: "age"},
|
|
|
|
|
&cli.Uint64Flag{Name: "bigage"},
|
|
|
|
|
},
|
|
|
|
|
EnableBashCompletion: true,
|
|
|
|
|
HideHelp: false,
|
|
|
|
|
HideVersion: false,
|
|
|
|
|
BashComplete: func(c *cli.Context) {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "lipstick\nkiss\nme\nlipstick\nringo\n")
|
|
|
|
|
},
|
|
|
|
|
Before: func(c *cli.Context) error {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "HEEEERE GOES\n")
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
After: func(c *cli.Context) error {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "Phew!\n")
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
CommandNotFound: func(c *cli.Context, command string) {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "Thar be no %q here.\n", command)
|
|
|
|
|
},
|
|
|
|
|
OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error {
|
|
|
|
|
if isSubcommand {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "WRONG: %#v\n", err)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
app.Action = func(c *cli.Context) error {
|
|
|
|
|
cli.DefaultAppComplete(c)
|
|
|
|
|
cli.HandleExitCoder(errors.New("not an exit coder, though"))
|
|
|
|
|
cli.ShowAppHelp(c)
|
|
|
|
|
cli.ShowCommandCompletions(c, "nope")
|
|
|
|
|
cli.ShowCommandHelp(c, "also-nope")
|
|
|
|
|
cli.ShowCompletions(c)
|
|
|
|
|
cli.ShowSubcommandHelp(c)
|
|
|
|
|
cli.ShowVersion(c)
|
|
|
|
|
|
|
|
|
|
categories := c.App.Categories
|
|
|
|
|
categories.AddCommand("sounds", &cli.Command{
|
|
|
|
|
Name: "bloop",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
for _, category := range c.App.Categories.Categories() {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "%s\n", category.Name)
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "%#v\n", category.VisibleCommands())
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "%#v\n", category.VisibleCommands())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Printf("%#v\n", c.App.Command("doo"))
|
|
|
|
|
if c.Bool("infinite") {
|
|
|
|
|
c.App.Run([]string{"app", "doo", "wop"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.Bool("forevar") {
|
|
|
|
|
c.App.RunAsSubcommand(c)
|
|
|
|
|
}
|
|
|
|
|
c.App.Setup()
|
|
|
|
|
fmt.Printf("%#v\n", c.App.VisibleCategories())
|
|
|
|
|
fmt.Printf("%#v\n", c.App.VisibleCommands())
|
|
|
|
|
fmt.Printf("%#v\n", c.App.VisibleFlags())
|
|
|
|
|
|
|
|
|
|
fmt.Printf("%#v\n", c.Args().First())
|
|
|
|
|
if c.Args().Len() > 0 {
|
|
|
|
|
fmt.Printf("%#v\n", c.Args().Get(1))
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("%#v\n", c.Args().Present())
|
|
|
|
|
fmt.Printf("%#v\n", c.Args().Tail())
|
|
|
|
|
|
|
|
|
|
set := flag.NewFlagSet("contrive", 0)
|
|
|
|
|
nc := cli.NewContext(c.App, set, c)
|
|
|
|
|
|
|
|
|
|
fmt.Printf("%#v\n", nc.Args())
|
|
|
|
|
fmt.Printf("%#v\n", nc.Bool("nope"))
|
|
|
|
|
fmt.Printf("%#v\n", !nc.Bool("nerp"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Duration("howlong"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Float64("hay"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Generic("bloop"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Int64("bonk"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Int64Slice("burnks"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Int("bips"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.IntSlice("blups"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.String("snurt"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.StringSlice("snurkles"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Uint("flub"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Uint64("florb"))
|
|
|
|
|
|
|
|
|
|
fmt.Printf("%#v\n", nc.FlagNames())
|
|
|
|
|
fmt.Printf("%#v\n", nc.IsSet("wat"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Set("wat", "nope"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.NArg())
|
|
|
|
|
fmt.Printf("%#v\n", nc.NumFlags())
|
|
|
|
|
fmt.Printf("%#v\n", nc.Lineage()[1])
|
|
|
|
|
|
|
|
|
|
nc.Set("wat", "also-nope")
|
|
|
|
|
|
|
|
|
|
ec := cli.Exit("ohwell", 86)
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "%d", ec.ExitCode())
|
|
|
|
|
fmt.Printf("made it!\n")
|
|
|
|
|
return ec
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "WRONG: %#v\n", err)
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
|
cli.DefaultAppComplete(c)
|
|
|
|
|
cli.HandleExitCoder(errors.New("not an exit coder, though"))
|
|
|
|
|
cli.ShowAppHelp(c)
|
|
|
|
|
cli.ShowCommandCompletions(c, "nope")
|
|
|
|
|
cli.ShowCommandHelp(c, "also-nope")
|
|
|
|
|
cli.ShowCompletions(c)
|
|
|
|
|
cli.ShowSubcommandHelp(c)
|
|
|
|
|
cli.ShowVersion(c)
|
|
|
|
|
|
|
|
|
|
categories := c.App.Categories
|
|
|
|
|
categories.AddCommand("sounds", &cli.Command{
|
|
|
|
|
Name: "bloop",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
for _, category := range c.App.Categories.Categories() {
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "%s\n", category.Name)
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "%#v\n", category.VisibleCommands())
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "%#v\n", category.VisibleCommands())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Printf("%#v\n", c.App.Command("doo"))
|
|
|
|
|
if c.Bool("infinite") {
|
|
|
|
|
c.App.Run([]string{"app", "doo", "wop"})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.Bool("forevar") {
|
|
|
|
|
c.App.RunAsSubcommand(c)
|
|
|
|
|
}
|
|
|
|
|
c.App.Setup()
|
|
|
|
|
fmt.Printf("%#v\n", c.App.VisibleCategories())
|
|
|
|
|
fmt.Printf("%#v\n", c.App.VisibleCommands())
|
|
|
|
|
fmt.Printf("%#v\n", c.App.VisibleFlags())
|
|
|
|
|
|
|
|
|
|
fmt.Printf("%#v\n", c.Args().First())
|
|
|
|
|
if c.Args().Len() > 0 {
|
|
|
|
|
fmt.Printf("%#v\n", c.Args().Get(1))
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("%#v\n", c.Args().Present())
|
|
|
|
|
fmt.Printf("%#v\n", c.Args().Tail())
|
|
|
|
|
|
|
|
|
|
set := flag.NewFlagSet("contrive", 0)
|
|
|
|
|
nc := cli.NewContext(c.App, set, c)
|
|
|
|
|
|
|
|
|
|
fmt.Printf("%#v\n", nc.Args())
|
|
|
|
|
fmt.Printf("%#v\n", nc.Bool("nope"))
|
|
|
|
|
fmt.Printf("%#v\n", !nc.Bool("nerp"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Duration("howlong"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Float64("hay"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Generic("bloop"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Int64("bonk"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Int64Slice("burnks"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Int("bips"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.IntSlice("blups"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.String("snurt"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.StringSlice("snurkles"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Uint("flub"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Uint64("florb"))
|
|
|
|
|
|
|
|
|
|
fmt.Printf("%#v\n", nc.FlagNames())
|
|
|
|
|
fmt.Printf("%#v\n", nc.IsSet("wat"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.Set("wat", "nope"))
|
|
|
|
|
fmt.Printf("%#v\n", nc.NArg())
|
|
|
|
|
fmt.Printf("%#v\n", nc.NumFlags())
|
|
|
|
|
fmt.Printf("%#v\n", nc.Lineage()[1])
|
|
|
|
|
|
|
|
|
|
nc.Set("wat", "also-nope")
|
|
|
|
|
|
|
|
|
|
ec := cli.Exit("ohwell", 86)
|
|
|
|
|
fmt.Fprintf(c.App.Writer, "%d", ec.ExitCode())
|
|
|
|
|
fmt.Printf("made it!\n")
|
|
|
|
|
return ec
|
|
|
|
|
},
|
|
|
|
|
Metadata: map[string]interface{}{
|
|
|
|
|
"layers": "many",
|
|
|
|
|
"explicable": false,
|
|
|
|
|
"whatever-values": 19.99,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if os.Getenv("HEXY") != "" {
|
|
|
|
@ -1275,12 +1285,6 @@ func main() {
|
|
|
|
|
app.ErrWriter = &hexWriter{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Metadata = map[string]interface{}{
|
|
|
|
|
"layers": "many",
|
|
|
|
|
"explicable": false,
|
|
|
|
|
"whatever-values": 19.99,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|