-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathroot.go
More file actions
90 lines (78 loc) · 2.82 KB
/
root.go
File metadata and controls
90 lines (78 loc) · 2.82 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package root
import (
"os"
"github.com/spf13/cobra"
bakeCmd "github.com/depot/cli/pkg/cmd/bake"
"github.com/depot/cli/pkg/cmd/blog"
buildCmd "github.com/depot/cli/pkg/cmd/build"
cacheCmd "github.com/depot/cli/pkg/cmd/cache"
cargoCmd "github.com/depot/cli/pkg/cmd/cargo"
ciCmd "github.com/depot/cli/pkg/cmd/ci"
claudeCmd "github.com/depot/cli/pkg/cmd/claude"
dockerCmd "github.com/depot/cli/pkg/cmd/docker"
"github.com/depot/cli/pkg/cmd/exec"
"github.com/depot/cli/pkg/cmd/gocache"
"github.com/depot/cli/pkg/cmd/image"
initCmd "github.com/depot/cli/pkg/cmd/init"
"github.com/depot/cli/pkg/cmd/list"
loginCmd "github.com/depot/cli/pkg/cmd/login"
logout "github.com/depot/cli/pkg/cmd/logout"
"github.com/depot/cli/pkg/cmd/org"
"github.com/depot/cli/pkg/cmd/projects"
"github.com/depot/cli/pkg/cmd/pull"
"github.com/depot/cli/pkg/cmd/pulltoken"
"github.com/depot/cli/pkg/cmd/push"
"github.com/depot/cli/pkg/cmd/registry"
sandboxCmd "github.com/depot/cli/pkg/cmd/sandbox"
versionCmd "github.com/depot/cli/pkg/cmd/version"
"github.com/depot/cli/pkg/config"
)
func NewCmdRoot(version, buildDate string) *cobra.Command {
var dockerConfig string
var cmd = &cobra.Command{
Use: "depot <command> [flags]",
Short: "Depot CLI",
SilenceUsage: true,
Run: func(cmd *cobra.Command, args []string) {
_ = cmd.Usage()
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if dockerConfig != "" {
os.Setenv("DOCKER_CONFIG", dockerConfig)
}
},
}
// Initialize config
_ = config.NewConfig()
formattedVersion := versionCmd.Format(version, buildDate)
cmd.SetVersionTemplate(formattedVersion)
cmd.Version = formattedVersion
cmd.Flags().Bool("version", false, "Print the version and exit")
cmd.PersistentFlags().StringVar(&dockerConfig, "config", "", "Override the location of Docker client config files")
_ = cmd.PersistentFlags().MarkHidden("config")
// Child commands
cmd.AddCommand(bakeCmd.NewCmdBake())
cmd.AddCommand(blog.NewCmdBlog())
cmd.AddCommand(buildCmd.NewCmdBuild())
cmd.AddCommand(cacheCmd.NewCmdCache())
cmd.AddCommand(cargoCmd.NewCmdCargo())
cmd.AddCommand(claudeCmd.NewCmdClaude())
cmd.AddCommand(image.NewCmdImage())
cmd.AddCommand(initCmd.NewCmdInit())
cmd.AddCommand(list.NewCmdList())
cmd.AddCommand(loginCmd.NewCmdLogin())
cmd.AddCommand(logout.NewCmdLogout())
cmd.AddCommand(pull.NewCmdPull())
cmd.AddCommand(pulltoken.NewCmdPullToken())
cmd.AddCommand(push.NewCmdPush())
cmd.AddCommand(versionCmd.NewCmdVersion(version, buildDate))
cmd.AddCommand(dockerCmd.NewCmdConfigureDocker())
cmd.AddCommand(registry.NewCmdRegistry())
cmd.AddCommand(org.NewCmdOrg())
cmd.AddCommand(projects.NewCmdProjects())
cmd.AddCommand(gocache.NewCmdGoCache())
cmd.AddCommand(exec.NewCmdExec())
cmd.AddCommand(ciCmd.NewCmdCI())
cmd.AddCommand(sandboxCmd.NewCmdSandbox())
return cmd
}