Add info and reset commands
This commit is contained in:
parent
898332064b
commit
5055eaa88a
|
@ -9,6 +9,7 @@ import (
|
|||
_ "github.com/ooni/probe-cli/internal/cli/list"
|
||||
_ "github.com/ooni/probe-cli/internal/cli/nettest"
|
||||
_ "github.com/ooni/probe-cli/internal/cli/onboard"
|
||||
_ "github.com/ooni/probe-cli/internal/cli/reset"
|
||||
_ "github.com/ooni/probe-cli/internal/cli/run"
|
||||
_ "github.com/ooni/probe-cli/internal/cli/show"
|
||||
_ "github.com/ooni/probe-cli/internal/cli/upload"
|
||||
|
|
|
@ -10,8 +10,18 @@ func init() {
|
|||
cmd := root.Command("info", "Display information about OONI Probe")
|
||||
|
||||
cmd.Action(func(_ *kingpin.ParseContext) error {
|
||||
log.Info("Info")
|
||||
log.Error("this function is not implemented")
|
||||
ctx, err := root.Init()
|
||||
if err != nil {
|
||||
log.Errorf("%s", err)
|
||||
return err
|
||||
}
|
||||
log.WithFields(log.Fields{
|
||||
"path": ctx.Home,
|
||||
}).Info("Home")
|
||||
log.WithFields(log.Fields{
|
||||
"path": ctx.TempDir,
|
||||
}).Info("TempDir")
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
30
internal/cli/reset/reset.go
Normal file
30
internal/cli/reset/reset.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package clean
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/alecthomas/kingpin"
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/internal/cli/root"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := root.Command("reset", "Cleanup an old or experimental installation")
|
||||
force := cmd.Flag("force", "Force deleting the OONI Home").Bool()
|
||||
|
||||
cmd.Action(func(_ *kingpin.ParseContext) error {
|
||||
ctx, err := root.Init()
|
||||
if err != nil {
|
||||
log.Errorf("%s", err)
|
||||
return err
|
||||
}
|
||||
if *force == true {
|
||||
os.RemoveAll(ctx.Home)
|
||||
log.Infof("Deleted %s", ctx.Home)
|
||||
} else {
|
||||
log.Infof("Run with --force to delete %s", ctx.Home)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user