-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
140 lines (131 loc) · 3.35 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package main
import (
"log"
"os"
"github.com/fatih/color"
"github.com/urfave/cli/v2"
)
const version = "0.8"
func handleError(err error) {
log.Fatalln(err)
}
var app = cli.NewApp()
var cRed *color.Color = color.New(color.FgRed)
var cYellow *color.Color = color.New(color.FgYellow)
var cGreen *color.Color = color.New(color.FgGreen)
var cWhite *color.Color = color.New(color.FgWhite)
var cGrey *color.Color = color.New(color.FgWhite)
func main() {
app := &cli.App{
Name: "Rosti.cz CLI",
Usage: "CLI application to manage projects hosted on Rosti.cz",
UsageText: "This command line tool reads Rostifile located in the current work directory and runs different commands with parameters defined in this file.\n\n rostictl [global options] command [command options] [arguments...]",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "no-color",
Aliases: []string{"nocolor"},
Usage: "Terminal output without colors",
},
},
Before: noColor,
Commands: []*cli.Command{
{
Name: "up",
Aliases: []string{},
Usage: "Deploys new or existing application",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "company",
Aliases: []string{"c"},
Value: 0,
Usage: "Company ID",
},
&cli.BoolFlag{
Name: "force-init",
Usage: "Runs initialization commands even if the application exists.",
},
},
Action: commandUp,
},
{
Name: "down",
Aliases: []string{"stop"},
Usage: "Turns the application off but doesn't remove it",
Action: commandDown,
},
{
Name: "start",
Aliases: []string{},
Usage: "Turns the application on without deploying any code",
Action: commandStart,
},
{
Name: "remove",
Aliases: []string{"rm"},
Usage: "Removes the application",
Action: commandRemove,
},
{
Name: "status",
Aliases: []string{},
Usage: "Returns status of the application",
Action: commandStatus,
},
{
Name: "plans",
Aliases: []string{},
Usage: "Prints list of available plans you can use in Rostifile",
Action: commandPlans,
},
{
Name: "companies",
Aliases: []string{},
Usage: "Prints list of companies you are member of.",
Action: commandCompanies,
},
{
Name: "runtimes",
Aliases: []string{},
Usage: "Prints list of available runtimes you can use in Rostifile",
Action: commandRuntimes,
},
{
Name: "init",
Aliases: []string{},
Usage: "Creates a new Rostifile in the current working directory",
Action: commandInit,
},
{
Name: "rostifile",
Aliases: []string{},
Usage: "Read Rostifile into internal structure and encodes it again (for debugging)",
Action: commandRostifile,
},
{
Name: "import",
Aliases: []string{},
Usage: "Imports existing application into a current working directory (creates .rosti.state, rewrites existing one if there is any)",
Action: commandImport,
Flags: []cli.Flag{
&cli.IntFlag{
Name: "company",
Aliases: []string{"c"},
Value: 0,
Usage: "Company ID",
},
},
},
{
Name: "version",
Aliases: []string{},
Usage: "Prints version of this binary",
Action: commandVersion,
},
// backup
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}