-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
44 lines (37 loc) · 853 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/hidu/cmd2http/internal"
)
var configPath = flag.String("conf", "./conf/app.toml", "app config file")
var listen = flag.String("listen", "", "overwrite the Listen Addr in the config file")
var users = flag.String("users", "", `overwrite the Users in the config file.
e.g.:
user1:psw1 --> Only one user
user1:psw1;user2:psw2 --> Two users
no --> No login required
`)
func main() {
flag.Parse()
server := internal.NewServer(*configPath)
if *listen != "" {
server.SetListen(*listen)
}
if *users != "" {
server.SetUsers(*users)
}
log.Println("exit:", server.Run())
}
func init() {
df := flag.Usage
flag.Usage = func() {
df()
fmt.Fprint(os.Stderr, `
convert CLI as HTTP service
Site: https://github.com/hidu/cmd2http/
`)
}
}