2022-08-15 00:11:56 +00:00
|
|
|
---
|
|
|
|
tags:
|
|
|
|
- v1
|
|
|
|
---
|
|
|
|
|
2022-08-14 22:49:05 +00:00
|
|
|
For additional organization in apps that have many subcommands, you can
|
|
|
|
associate a category for each command to group them together in the help
|
|
|
|
output.
|
|
|
|
|
|
|
|
E.g.
|
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
|
|
|
app.Commands = []cli.Command{
|
|
|
|
{
|
|
|
|
Name: "noop",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "add",
|
|
|
|
Category: "Template actions",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "remove",
|
|
|
|
Category: "Template actions",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
err := app.Run(os.Args)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Will include:
|
|
|
|
|
|
|
|
```
|
|
|
|
COMMANDS:
|
|
|
|
noop
|
|
|
|
|
|
|
|
Template actions:
|
|
|
|
add
|
|
|
|
remove
|
|
|
|
```
|