-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
root.go
66 lines (58 loc) · 1.37 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
64
65
66
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0
package cmd
import (
"context"
"fmt"
"os"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/ory/cli/buildinfo"
"github.com/ory/cli/cmd/cloudx"
"github.com/ory/cli/cmd/cloudx/client"
"github.com/ory/cli/cmd/cloudx/proxy"
"github.com/ory/kratos/cmd/jsonnet"
"github.com/ory/x/cmdx"
)
func NewRootCmd() *cobra.Command {
c := &cobra.Command{
Use: "ory",
Short: "The ORY CLI",
}
c.AddCommand(devCommands...)
c.AddCommand(
cloudx.NewAuthCmd(),
cloudx.NewCreateCmd(),
jsonnet.NewFormatCmd(),
jsonnet.NewLintCmd(),
cloudx.NewDeleteCmd(),
cloudx.NewGetCmd(),
cloudx.NewUseCmd(),
cloudx.NewListCmd(),
cloudx.NewImportCmd(),
cloudx.NewOpenCmd(),
cloudx.NewPatchCmd(),
cloudx.NewParseCmd(),
cloudx.NewPerformCmd(),
proxy.NewProxyCommand("ory", buildinfo.Version),
proxy.NewTunnelCommand("ory", buildinfo.Version),
cloudx.NewUpdateCmd(),
cloudx.NewValidateCmd(),
cloudx.NewRevokeCmd(),
cloudx.NewIntrospectCmd(),
cloudx.NewIsCmd(),
versionCmd,
)
cmdx.EnableUsageTemplating(c)
return c
}
func Execute() {
ctx := client.ContextWithClient(context.Background())
rootCmd := NewRootCmd()
if err := rootCmd.ExecuteContext(ctx); err != nil {
if !errors.Is(err, cmdx.ErrNoPrintButFail) {
_, _ = fmt.Fprintln(rootCmd.ErrOrStderr(), err)
}
os.Exit(1)
}
}