Example #1
0
// ProjectEvents listen for real-time events of containers.
func ProjectEvents(p project.APIProject, c *cli.Context) error {
	evts, err := p.Events(context.Background(), c.Args()...)
	if err != nil {
		return err
	}
	var printfn func(events.ContainerEvent)

	if c.Bool("json") {
		printfn = printJSON
	} else {
		printfn = printStd
	}
	for event := range evts {
		printfn(event)
	}
	return nil
}