-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrvm.go
111 lines (102 loc) · 2.17 KB
/
grvm.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package main
import (
"fmt"
"os"
"github.com/codegangsta/cli"
)
const (
rubyBuildRepo = "https://github.com/rbenv/ruby-build.git"
latestReleaseUrl = "https://api.github.com/repos/Bugagazavr/grvm/releases/latest"
)
// System
var version = ""
// ENVs
var currentHomeEnv = os.Getenv("HOME")
var grvmRubyEnv = os.Getenv("grvm_ruby")
var currentPathEnv = os.Getenv("PATH")
// Directories
var grvmDirectory = fmt.Sprintf("%s/.grvm", currentHomeEnv)
var rubyBuildDirectory = fmt.Sprintf("%s/ruby-build", grvmDirectory)
var rubiesDirectory = fmt.Sprintf("%s/rubies", grvmDirectory)
var gemsDirectory = fmt.Sprintf("%s/gems", grvmDirectory)
// Paths
var rubyBuildExecutable = fmt.Sprintf("%s/bin/ruby-build", rubyBuildDirectory)
var dbPath = fmt.Sprintf("%s/grvm.db", grvmDirectory)
func main() {
app := cli.NewApp()
app.Name = "GRVM"
app.Usage = "GRVM"
app.Version = version
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "shell, s",
},
}
app.Commands = []cli.Command{
{
Name: "list",
Aliases: []string{"l"},
Usage: "Show list installed rubies",
Action: GetList,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "known, k",
},
},
},
{
Name: "env",
Aliases: []string{"e"},
Usage: "Show env for ruby version",
Action: GetEnv,
},
{
Name: "set",
Aliases: []string{"s"},
Usage: "Set current ruby",
Action: set,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "default, d",
},
},
},
{
Name: "doctor",
Aliases: []string{"d"},
Usage: "Fixes all bugs",
Action: GetDoctor,
},
{
Name: "update",
Aliases: []string{"u"},
Usage: "Updates available rubies",
Action: GetUpdate,
},
{
Name: "install",
Aliases: []string{"i"},
Usage: "Installs ruby",
Action: GetInstall,
},
{
Name: "uninstall",
Aliases: []string{"ui"},
Usage: "grvm uninstall <ruby_version>",
Action: GetUninstall,
},
{
Name: "upgrade",
Aliases: []string{"ug"},
Usage: "Get upgrade information",
Action: GetUpgrade,
},
{
Name: "hook",
Aliases: []string{"h"},
Usage: "Hook to read Gemfile",
Action: GetHook,
},
}
app.Run(os.Args)
}