-
Notifications
You must be signed in to change notification settings - Fork 361
/
resources.go
38 lines (29 loc) · 928 Bytes
/
resources.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/stripe/stripe-cli/pkg/ansi"
"github.com/stripe/stripe-cli/pkg/validators"
)
type resourcesCmd struct {
cmd *cobra.Command
}
func newResourcesCmd() *resourcesCmd {
rc := &resourcesCmd{}
rc.cmd = &cobra.Command{
Use: "resources",
Args: validators.NoArgs,
Short: "List resource commands",
}
rc.cmd.SetHelpTemplate(getResourcesHelpTemplate())
return rc
}
func getResourcesHelpTemplate() string {
// This template uses `.Parent` to access subcommands on the root command.
return fmt.Sprintf(`%s{{range $index, $cmd := .Parent.Commands}}{{if (or (eq (index $.Parent.Annotations $cmd.Name) "resource") (eq (index $.Parent.Annotations $cmd.Name) "namespace"))}}
{{rpad $cmd.Name $cmd.NamePadding }} {{$cmd.Short}}{{end}}{{end}}
Use "stripe [command] --help" for more information about a command.
`,
ansi.Bold("Available commands:"),
)
}