-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
49 lines (40 loc) · 1.12 KB
/
main.go
File metadata and controls
49 lines (40 loc) · 1.12 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
package main
import (
"encoding/json"
"fmt"
"os"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/jgfranco17/devops/cli/core"
"github.com/jgfranco17/devops/cli/executor"
_ "embed" // Required for the //go:embed directive
)
//go:embed specs.json
var embeddedConfig []byte
type ProjectMetadata struct {
Author string `json:"author"`
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version"`
Repository string `json:"repository"`
}
func main() {
var metadata ProjectMetadata
if err := json.Unmarshal(embeddedConfig, &metadata); err != nil {
fmt.Printf("Error unmarshaling config: %v\n", err)
os.Exit(1)
}
executor := &executor.DefaultExecutor{}
command := core.NewCommandRegistry(metadata.Name, metadata.Description, metadata.Version)
commandsList := []*cobra.Command{
core.GetBuildCommand(executor),
core.GetTestCommand(executor),
core.GetDoctorCommand(executor),
core.GetManifestCommand(),
core.GetDocsCommand(),
}
command.RegisterCommands(commandsList)
if err := command.Execute(); err != nil {
log.Error(err.Error())
}
}