-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsdctl.go
More file actions
40 lines (34 loc) · 723 Bytes
/
sdctl.go
File metadata and controls
40 lines (34 loc) · 723 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
package main
import (
"fmt"
"os"
"github.com/tk3fftk/sdctl/command"
"github.com/tk3fftk/sdctl/pkg/sdapi"
"github.com/tk3fftk/sdctl/pkg/sdctl_context"
"github.com/tk3fftk/sdctl/util"
)
func failureExit(err error) {
if err != nil {
fmt.Fprintf(os.Stderr, "[ERROR] %v\n", err)
}
os.Exit(1)
}
func main() {
configPATH, err := util.ConfigPATH()
if err != nil {
failureExit(err)
}
config, err := sdctl_context.LoadConfig(configPATH, false)
if err != nil {
failureExit(err)
}
sdctx := config.SdctlContexts[config.CurrentContext]
api, err := sdapi.New(sdctx, nil)
if err != nil {
failureExit(err)
}
cmd := command.NewCmd(config, api)
if err := cmd.Execute(); err != nil {
failureExit(err)
}
}