-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
executable file
·42 lines (37 loc) · 854 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
package main
import (
log "github.com/Sirupsen/logrus"
"github.com/urfave/cli"
"os"
"socker/command"
)
func main() {
//use opensource project 'cli' to define app and parse flags
app := cli.NewApp()
app.Name = "socker"
app.Commands = []*cli.Command{
&command.RunCommand,
&command.InitCommand,
&command.CommitCommand,
&command.ListCommand,
&command.LogCommand,
&command.ExecCommand,
&command.StopCommand,
&command.NetworkCommand,
&command.RemoveCommand,
&command.ImageCommand,
}
//init logrus
app.Before = func(context *cli.Context) error {
//set log as JSON formatter
log.SetFormatter(&log.JSONFormatter{})
log.SetOutput(os.Stdout)
return nil
}
//output args you had just type-in
sockerCommand := os.Args
log.Printf("args: %s", sockerCommand)
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}