-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathroot.go
63 lines (58 loc) · 1.88 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
59
60
61
62
63
package cmd
import (
"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/cmdx"
"github.com/spf13/cobra"
cli "github.com/spf13/cobra"
)
func New(cliConfig *Config) *cli.Command {
var cmd = &cli.Command{
Use: "frontier <command> <subcommand> [flags]",
Short: "A cloud native role-based authorization server",
Long: heredoc.Doc(`
A cloud native role-based authorization server.`),
SilenceUsage: true,
SilenceErrors: true,
Annotations: map[string]string{
"group": "core",
"help:learn": heredoc.Doc(`
Use 'frontier <command> <subcommand> --help' for info about a command.
Read the manual at https://raystack.github.io/frontier/
`),
"help:feedback": heredoc.Doc(`
Open an issue here https://github.com/raystack/frontier/issues
`),
"help:environment": heredoc.Doc(`
See 'frontier help environment' for the list of supported environment variables.
`),
},
}
cmd.PersistentPreRunE = func(subCmd *cobra.Command, args []string) error {
if isClientCLI(subCmd) {
if err := overrideClientConfigHost(subCmd, cliConfig); err != nil {
return err
}
}
return nil
}
cmd.AddCommand(ServerCommand())
cmd.AddCommand(NamespaceCommand(cliConfig))
cmd.AddCommand(UserCommand(cliConfig))
cmd.AddCommand(OrganizationCommand(cliConfig))
cmd.AddCommand(GroupCommand(cliConfig))
cmd.AddCommand(ProjectCommand(cliConfig))
cmd.AddCommand(RoleCommand(cliConfig))
cmd.AddCommand(PermissionCommand(cliConfig))
cmd.AddCommand(PolicyCommand(cliConfig))
cmd.AddCommand(SeedCommand(cliConfig))
cmd.AddCommand(configCommand())
cmd.AddCommand(versionCommand())
cmd.AddCommand(PreferencesCommand(cliConfig))
// Help topics
cmdx.SetHelp(cmd)
cmd.AddCommand(cmdx.SetCompletionCmd("frontier"))
cmd.AddCommand(cmdx.SetHelpTopicCmd("environment", envHelp))
cmd.AddCommand(cmdx.SetHelpTopicCmd("auth", authHelp))
cmd.AddCommand(cmdx.SetRefCmd(cmd))
return cmd
}