forked from cristianoliveira/ergo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (48 loc) · 898 Bytes
/
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
package main
import (
"flag"
"fmt"
"github.com/cristianoliveira/ergo/commands"
"github.com/cristianoliveira/ergo/proxy"
"os"
)
const VERSION = "0.0.4"
const USAGE = `
Ergo proxy.
The local proxy agent for multiple services development.
Usage:
ergo [options]
ergo run [options]
ergo list
Options:
-h Shows this message.
-v Shows ergs's version.
`
func main() {
var command string = "run"
if len(os.Args) > 1 {
command = os.Args[1]
}
help := flag.Bool("h", false, "Shows ergs's help.")
version := flag.Bool("v", false, "Shows ergs's version.")
flag.Parse()
if *help {
fmt.Println(USAGE)
os.Exit(0)
}
if *version {
fmt.Println(VERSION)
os.Exit(0)
}
config := proxy.LoadConfig("./.ergo")
switch command {
case "list":
commands.List(config)
os.Exit(0)
case "run":
commands.Run(config)
default:
fmt.Println(USAGE)
os.Exit(0)
}
}