ooni-probe-cli/internal/cli/show/show.go

29 lines
736 B
Go
Raw Normal View History

package nettest
import (
"github.com/alecthomas/kingpin"
"github.com/apex/log"
"github.com/ooni/probe-cli/internal/cli/root"
2019-10-02 18:23:14 +02:00
"github.com/ooni/probe-cli/internal/database"
"github.com/ooni/probe-cli/internal/output"
)
func init() {
cmd := root.Command("show", "Show a specific measurement")
msmtID := cmd.Arg("id", "the id of the measurement to show").Required().Int64()
cmd.Action(func(_ *kingpin.ParseContext) error {
2019-10-02 18:23:14 +02:00
ctx, err := root.Init()
if err != nil {
log.WithError(err).Error("failed to initialize root context")
return err
}
msmt, err := database.GetMeasurementJSON(ctx.DB(), *msmtID)
2019-10-02 18:23:14 +02:00
if err != nil {
log.Errorf("error: %v", err)
return err
}
output.MeasurementJSON(msmt)
return nil
})
}