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

36 lines
743 B
Go
Raw Normal View History

2018-06-25 16:31:44 +02:00
package onboard
import (
"github.com/alecthomas/kingpin"
2018-07-30 18:51:44 +02:00
"github.com/apex/log"
2018-06-25 16:31:44 +02:00
"github.com/ooni/probe-cli/internal/cli/root"
2018-06-25 17:14:29 +02:00
"github.com/ooni/probe-cli/internal/onboard"
2018-06-25 16:31:44 +02:00
)
func init() {
cmd := root.Command("onboard", "Starts the onboarding process")
2018-07-30 18:51:44 +02:00
yes := cmd.Flag("yes", "Answer yes to all the onboarding questions.").Bool()
2018-06-25 16:31:44 +02:00
cmd.Action(func(_ *kingpin.ParseContext) error {
ctx, err := root.Init()
if err != nil {
return err
}
2018-07-30 18:51:44 +02:00
if *yes == true {
ctx.Config.Lock()
ctx.Config.InformedConsent = true
ctx.Config.Unlock()
if err := ctx.Config.Write(); err != nil {
log.WithError(err).Error("failed to write config file")
return err
}
return nil
}
2018-06-25 17:14:29 +02:00
return onboard.Onboarding(ctx.Config)
2018-06-25 16:31:44 +02:00
})
}