-
Notifications
You must be signed in to change notification settings - Fork 1
/
doenv.go
69 lines (57 loc) · 1.46 KB
/
doenv.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
package main
import (
"github.com/codegangsta/cli"
"os"
"fmt"
"github.com/tucnak/store"
. "github.com/popcorp/doenv/lib"
. "github.com/popcorp/doenv/commands"
)
func main() {
store.SetApplicationName("doenv")
LoadSettings()
var settings = GetSettings()
app := cli.NewApp()
app.Name = "doenv"
app.Usage = "It's like virtualenv, but powered by DigitalOcean"
app.Version = "1.0.0"
app.Author = "PunKeel <punkeel@me.com>"
if settings.PersonnalApiToken == "" {
app.Action = func(c *cli.Context) {
fmt.Println("Well, looks like you haven't defined your Personnal API token yet.")
fmt.Println("To grab one, simply go to https://cloud.digitalocean.com/settings/applications and generate a new token")
fmt.Println("Then, asusming the token is '421gtp', simply run `doenv set-token 421gtp`")
os.Exit(1)
}
app.Commands = []cli.Command{SetTokenCommand}
app.Run(os.Args)
os.Exit(1)
}else {
UseClientToken(settings.PersonnalApiToken)
}
app.Action = func(c *cli.Context) {
if len(c.Args()) == 1 {
GuessCommand(c.Args().First())
}
cli.ShowAppHelp(c)
}
app.Commands = []cli.Command{
ListCommand,
CreateCommand,
EraseCommand,
RestoreCommand,
FreezeCommand,
SnapshotCommand,
SshCommand,
KeysCommand,
SetTokenCommand,
/**
* Disabled commands: they don't fit into this project.
* Kept because they're still cool & might be re-enabled lated
*/
// StatusCommand,
// StartCommand,
// StopCommand,
}
app.Run(os.Args)
}