-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathroot.go
More file actions
42 lines (33 loc) · 712 Bytes
/
root.go
File metadata and controls
42 lines (33 loc) · 712 Bytes
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
/*
Copyright © 2025 Codesphere Inc. <support@codesphere.com>
*/
package cmd
import (
"os"
"github.com/spf13/cobra"
)
type GlobalOptions struct {
apiUrl *string
}
func (o GlobalOptions) GetApiUrl() string {
if o.apiUrl != nil {
return *o.apiUrl
}
return GetApiUrl()
}
func Execute() {
var rootCmd = &cobra.Command{
Use: "cs",
Short: "The codesphere CLI",
Long: `Manage and debug resources deployed in Codesphere
via command line.`,
}
opts := GlobalOptions{}
addLogCmd(rootCmd, opts)
addListCmd(rootCmd, opts)
opts.apiUrl = rootCmd.PersistentFlags().StringP("api", "a", "", "URL of Codesphere API (can also be CS_API)")
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}