-
Notifications
You must be signed in to change notification settings - Fork 72
/
root.go
58 lines (49 loc) · 2.27 KB
/
root.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package root
import (
"github.com/redhat-developer/app-services-cli/pkg/cmd/cluster"
"github.com/redhat-developer/app-services-cli/pkg/cmd/completion"
"github.com/redhat-developer/app-services-cli/pkg/cmd/docs"
"github.com/redhat-developer/app-services-cli/pkg/cmd/kafka"
"github.com/redhat-developer/app-services-cli/pkg/cmd/login"
"github.com/redhat-developer/app-services-cli/pkg/cmd/logout"
"github.com/redhat-developer/app-services-cli/pkg/cmd/registry"
"github.com/redhat-developer/app-services-cli/pkg/cmd/serviceaccount"
"github.com/redhat-developer/app-services-cli/pkg/cmd/status"
cliversion "github.com/redhat-developer/app-services-cli/pkg/cmd/version"
"github.com/redhat-developer/app-services-cli/pkg/cmd/whoami"
"github.com/redhat-developer/app-services-cli/pkg/core/cmdutil/flagutil"
"github.com/redhat-developer/app-services-cli/pkg/shared/factory"
"github.com/spf13/cobra"
)
func NewRootCommand(f *factory.Factory, version string) *cobra.Command {
cmd := &cobra.Command{
SilenceUsage: true,
SilenceErrors: true,
Use: "rhoas <command> <subcommand> [flags]",
Short: f.Localizer.MustLocalize("root.cmd.shortDescription"),
Long: f.Localizer.MustLocalize("root.cmd.longDescription"),
Example: f.Localizer.MustLocalize("root.cmd.example"),
}
fs := cmd.PersistentFlags()
flagutil.VerboseFlag(fs)
// this flag comes out of the box, but has its own basic usage text, so this overrides that
var help bool
fs.BoolVarP(&help, "help", "h", false, f.Localizer.MustLocalize("root.cmd.flag.help.description"))
cmd.Flags().Bool("version", false, f.Localizer.MustLocalize("root.cmd.flag.version.description"))
cmd.Version = version
// pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
// Child commands
cmd.AddCommand(login.NewLoginCmd(f))
cmd.AddCommand(logout.NewLogoutCommand(f))
cmd.AddCommand(kafka.NewKafkaCommand(f))
cmd.AddCommand(serviceaccount.NewServiceAccountCommand(f))
cmd.AddCommand(cluster.NewClusterCommand(f))
cmd.AddCommand(status.NewStatusCommand(f))
cmd.AddCommand(completion.NewCompletionCommand(f))
cmd.AddCommand(whoami.NewWhoAmICmd(f))
cmd.AddCommand(cliversion.NewVersionCmd(f))
// Registry commands
cmd.AddCommand(registry.NewServiceRegistryCommand(f))
cmd.AddCommand(docs.NewDocsCmd(f))
return cmd
}