Debian Codegraph @

docs/v2/examples/subcommands-categories.md

raw symbols SCIP
1 ---
2 tags:
3 - v2
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
19 "github.com/urfave/cli/v2"
20 )
21
22 func main() {
23 app := &cli.App{
24 Commands: []*cli.Command{
25 {
26 Name: "noop",
27 },
28 {
29 Name: "add",
30 Category: "template",
31 },
32 {
33 Name: "remove",
34 Category: "template",
35 },
36 },
37 }
38
39 if err := app.Run(os.Args); err != nil {
40 log.Fatal(err)
41 }
42 }
43 ```
44
45 Will include:
46
47 ```
48 COMMANDS:
49 noop
50
51 Template actions:
52 add
53 remove
54 ```