-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathroot.go
More file actions
44 lines (34 loc) · 857 Bytes
/
root.go
File metadata and controls
44 lines (34 loc) · 857 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
43
44
// Copyright (c) Codesphere Inc.
// SPDX-License-Identifier: Apache-2.0
package cmd
import (
"os"
"github.com/codesphere-cloud/cs-go/pkg/cs"
"github.com/spf13/cobra"
)
type GlobalOptions struct {
ApiUrl *string
}
func (o GlobalOptions) GetApiUrl() string {
if o.ApiUrl != nil {
return *o.ApiUrl
}
return cs.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)
addPipelinesCmd(rootCmd, opts)
addSetEnvVarCmd(rootCmd, opts)
opts.ApiUrl = rootCmd.PersistentFlags().StringP("api", "a", "https://codesphere.com/api", "URL of Codesphere API (can also be CS_API)")
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}