Debian Codegraph @

docs/v1/examples/subcommands-categories.md

raw symbols SCIP
1 ---
2 tags:
3 - v1
4 ---
5
6 For additional organization in apps that have many subcommands, you can
7 associate a category for each command to group them together in the help
8 output.
9
10 E.g.
11
12 ```go
13 package main
14
15 import (
16 "log"
17 "os"
18
19 "github.com/urfave/cli"
20 )
21
22 func main() {
23 app := cli.NewApp()
24
25 app.Commands = []cli.Command{
26 {
27 Name: "noop",
28 },
29 {
30 Name: "add",
31 Category: "Template actions",
32 },
33 {
34 Name: "remove",
35 Category: "Template actions",
36 },
37 }
38
39 err := app.Run(os.Args)
40 if err != nil {
41 log.Fatal(err)
42 }
43 }
44 ```
45
46 Will include:
47
48 ```
49 COMMANDS:
50 noop
51
52 Template actions:
53 add
54 remove
55 ```