-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
42 lines (34 loc) · 876 Bytes
/
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
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
// This represents the base command when called without any subcommands
func NewRootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "hydra",
Short: "Run and manage ORY Hydra",
}
RegisterCommandRecursive(cmd)
return cmd
}
func RegisterCommandRecursive(parent *cobra.Command) {
// Clients
migrateCmd := NewMigrateCmd()
parent.AddCommand(migrateCmd)
migrateCmd.AddCommand(NewMigrateSqlCmd())
serveCmd := NewServeCmd()
parent.AddCommand(serveCmd)
serveCmd.AddCommand(NewServeAdminCmd())
serveCmd.AddCommand(NewServePublicCmd())
serveCmd.AddCommand(NewServeAllCmd())
parent.AddCommand(NewVersionCmd())
}
// Execute adds all child commands to the root command sets flags appropriately.
func Execute() {
if err := NewRootCmd().Execute(); err != nil {
fmt.Println(err)
os.Exit(-1)
}
}