More progress towards release v3.10.0 (#320)

* chore: unvendor github.com/mitchellh/go-wordwrap

The library seems reasonably maintained and tested.

Part of https://github.com/ooni/probe/issues/1439

* fix(netx/quicdialer): ensure we handle all errors

Part of https://github.com/ooni/probe/issues/1439

* fix previous

* cleanup: remove unnecessary shutil fork

Part of https://github.com/ooni/probe/issues/1439

* doc: documented some undocumented functions

Part of https://github.com/ooni/probe/issues/1439

* fix(ooniprobe): rename mis-named function

Part of https://github.com/ooni/probe/issues/1439
This commit is contained in:
Simone Basso
2021-04-29 15:59:53 +02:00
committed by GitHub
parent de60fb0588
commit 1d70b81187
8 changed files with 33 additions and 399 deletions
+11 -4
View File
@@ -7,8 +7,8 @@ import (
"time"
"github.com/apex/log"
"github.com/mitchellh/go-wordwrap"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/database"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/utils"
)
// MeasurementJSON prints the JSON of a measurement
@@ -29,6 +29,7 @@ func Progress(key string, perc float64, eta float64, msg string) {
}).Info(msg)
}
// MeasurementSummaryData contains summary information on the measurement
type MeasurementSummaryData struct {
TotalRuntime float64
TotalCount int64
@@ -41,6 +42,7 @@ type MeasurementSummaryData struct {
StartTime time.Time
}
// MeasurementSummary emits the measurement summary
func MeasurementSummary(msmt MeasurementSummaryData) {
log.WithFields(log.Fields{
"type": "measurement_summary",
@@ -128,6 +130,7 @@ func ResultItem(result ResultItemData) {
}).Info("result item")
}
// ResultSummaryData contains the summary data of a result
type ResultSummaryData struct {
TotalTests int64
TotalDataUsageUp float64
@@ -135,6 +138,7 @@ type ResultSummaryData struct {
TotalNetworks int64
}
// ResultSummary emits the result summary
func ResultSummary(result ResultSummaryData) {
log.WithFields(log.Fields{
"type": "result_summary",
@@ -153,17 +157,20 @@ func SectionTitle(text string) {
}).Info(text)
}
// Paragraph makes a word-wrapped paragraph out of text
func Paragraph(text string) {
const width = 80
fmt.Println(utils.WrapString(text, width))
fmt.Println(wordwrap.WrapString(text, width))
}
// Bullet is like paragraph but with a bullet point in front
func Bullet(text string) {
const width = 80
fmt.Printf("• %s\n", utils.WrapString(text, width))
fmt.Printf("• %s\n", wordwrap.WrapString(text, width))
}
func PressEnterToContinue(text string) error {
// PressAnyKeyToContinue blocks until the user presses any key
func PressAnyKeyToContinue(text string) error {
fmt.Print(text)
_, err := bufio.NewReader(os.Stdin).ReadBytes('\n')
return err