-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (37 loc) · 877 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
package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/aaabhilash97/mock-http/lib/server"
)
var defaultDefLoc string
var definitions string
var address string
var debug bool
func init() {
userHome, err := os.UserHomeDir()
if err != nil {
log.Fatal(err)
}
defaultDefLoc = fmt.Sprintf("%s/.mock-http/definitions", userHome)
flag.StringVar(&definitions, "definitions", defaultDefLoc, "Mock definitions location")
flag.StringVar(&address, "address", "127.0.0.1:3000", "Address Ex: 3000, 0.0.0.0:3000")
flag.BoolVar(&debug, "debug", false, "Show debug info")
flag.Parse()
}
func main() {
err := os.MkdirAll(defaultDefLoc, os.ModePerm)
if err != nil {
log.Fatal(err)
}
err = server.StartServer(server.Options{
Address: address,
DefinitionsLocation: definitions,
Debug: debug,
})
if err != nil {
log.Fatal(err)
}
}