Skip to content

Commit

Permalink
Merge pull request #34 from ByteArena/feat-quiet-option
Browse files Browse the repository at this point in the history
Implement quiet mode for output
  • Loading branch information
Sven SAULEAU authored Dec 22, 2017
2 parents 4789676 + 0be4048 commit f0e5d57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/ba/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func makeapp() *cli.App {
cli.StringFlag{Name: "map", Value: "hexagon", Usage: "Name of the map used by the trainer"},
cli.BoolFlag{Name: "no-browser", Usage: "Disable automatic browser opening at start"},
cli.BoolFlag{Name: "debug", Usage: "Enable debug logging"},
cli.BoolFlag{Name: "quiet", Usage: "Decrease verbosity of the output"},
cli.BoolFlag{Name: "profile", Usage: "Enable execution profiling"},
cli.BoolFlag{Name: "dump-raw-comm", Usage: "Dump all the communication between the agent and the server"},
cli.IntFlag{Name: "duration", Usage: "If set, game will stop after this durarion (in seconds)"},
Expand All @@ -105,6 +106,7 @@ func makeapp() *cli.App {
mapName := c.String("map")
nobrowser := c.Bool("no-browser")
isDebug := c.Bool("debug")
isQuiet := c.Bool("quiet")
shouldProfile := c.Bool("profile")
dumpRaw := c.Bool("dump-raw-comm")
duration := c.Int("duration")
Expand All @@ -118,6 +120,7 @@ func makeapp() *cli.App {
recordFile,
agents,
isDebug,
isQuiet,
mapName,
shouldProfile,
dumpRaw,
Expand Down
9 changes: 7 additions & 2 deletions subcommand/train/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TrainAction(
recordFile string,
agentimages []string,
isDebug bool,
isQuiet bool,
mapName string,
shouldProfile,
dumpRaw bool,
Expand Down Expand Up @@ -156,13 +157,17 @@ func TrainAction(

switch t := msg.(type) {
case arenaserver.EventStatusGameUpdate:
fmt.Printf(GameColor("[game] %s\n"), t.Status)
if !isQuiet {
fmt.Printf(GameColor("[game] %s\n"), t.Status)
}

case arenaserver.EventAgentLog:
fmt.Printf(AgentColor("[agent] %s\n"), t.Value)

case arenaserver.EventLog:
fmt.Printf(LogColor("[log] %s\n"), t.Value)
if !isQuiet {
fmt.Printf(LogColor("[log] %s\n"), t.Value)
}

case arenaserver.EventDebug:
debug(t.Value)
Expand Down

0 comments on commit f0e5d57

Please sign in to comment.