-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
90 lines (80 loc) · 2.32 KB
/
main.go
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
//Kepler is a tool for helping developers work in the cli with github and other tools
//It's speciality is the management of multiple working issues and threading those together with pull requests
//Ideal audience would be a developer working across multiple repositories
package main
import (
"bytes"
"fmt"
"log"
"os"
"os/exec"
"path"
"runtime"
"github.com/AlexsJones/cli/cli"
"github.com/AlexsJones/kepler/commands/docker"
"github.com/AlexsJones/kepler/commands/github"
"github.com/AlexsJones/kepler/commands/kubebuilder"
"github.com/AlexsJones/kepler/commands/node"
"github.com/AlexsJones/kepler/commands/palette"
"github.com/AlexsJones/kepler/commands/storage"
"github.com/AlexsJones/kepler/commands/submodules"
"github.com/dimiro1/banner"
)
var version string = "HEAD"
//Ascii art
const b string = `
{{ .AnsiColor.Green }} _ _ ____ ____ __ ____ ____
{{ .AnsiColor.Green }}( )/ )( ___)( _ \( ) ( ___)( _ \
{{ .AnsiColor.Green }} ) ( )__) )___/ )(__ )__) ) /
{{ .AnsiColor.Green }}(_)\_)(____)(__) (____)(____)(_)\_)
{{ .AnsiColor.Default }}Kepler is a simple program for improving developer workflow.
{{ .AnsiColor.Default }}Type 'help' for commands!
{{ .AnsiColor.Default }}
`
func processVersion() {
_, filename, _, ok := runtime.Caller(0)
if ok {
p := path.Dir(filename)
if p != "" {
b, err := storage.Exists(p)
if err != nil {
log.Println(err.Error())
}
if b {
cmd := exec.Command("git", "describe", "--always", "--long", "--dirty")
cmd.Dir = p
out, err := cmd.Output()
if err != nil {
log.Println(err.Error())
}
if out != nil {
version = string(out)
}
}
}
}
if version != "" {
fmt.Printf("Running kepler version %s\n", version)
}
}
func main() {
banner.Init(os.Stdout, true, true, bytes.NewBufferString(b))
processVersion()
cli := cli.NewCli()
//Modules to add ----------------------------
kubebuilder.AddCommands(cli)
node.AddCommands(cli)
github.AddCommands(cli)
submodules.AddCommands(cli)
storage.AddCommands(cli)
palette.AddCommands(cli)
docker.AddCommands(cli)
//-------------------------------------------
//Additional commands
// Only automatically login if there is AccessToken set
if store := storage.GetInstance(); store.Github.AccessToken != "" {
github.Login()
}
//-------------------------------------------
cli.Run()
}