Debian Codegraph @

docs/v3/examples/subcommands/categories.md

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