Update flag name to avoid kingpin bugs
This commit is contained in:
parent
67485102c6
commit
024449375f
|
@ -124,7 +124,7 @@ Flags:
|
||||||
--resp-timeout=DURATION Timeout for full response reading
|
--resp-timeout=DURATION Timeout for full response reading
|
||||||
--socks5=ip:port Socks5 proxy
|
--socks5=ip:port Socks5 proxy
|
||||||
--auto-open-browser Specify whether auto open browser to show Web charts
|
--auto-open-browser Specify whether auto open browser to show Web charts
|
||||||
--not-clear Don't clear the histogram bar once its finished
|
--[no-]clean Clean the histogram bar once its finished. Default is true
|
||||||
--version Show application version.
|
--version Show application version.
|
||||||
|
|
||||||
Flags default values also read from env PLOW_SOME_FLAG, such as PLOW_TIMEOUT=5s equals to --timeout=5s
|
Flags default values also read from env PLOW_SOME_FLAG, such as PLOW_TIMEOUT=5s equals to --timeout=5s
|
||||||
|
|
4
main.go
4
main.go
|
@ -35,7 +35,7 @@ var (
|
||||||
socks5 = kingpin.Flag("socks5", "Socks5 proxy").PlaceHolder("ip:port").String()
|
socks5 = kingpin.Flag("socks5", "Socks5 proxy").PlaceHolder("ip:port").String()
|
||||||
|
|
||||||
autoOpenBrowser = kingpin.Flag("auto-open-browser", "Specify whether auto open browser to show Web charts").Bool()
|
autoOpenBrowser = kingpin.Flag("auto-open-browser", "Specify whether auto open browser to show Web charts").Bool()
|
||||||
notClearBar = kingpin.Flag("not-clear", "Don't clear the histogram bar once its finished").Bool()
|
clean = kingpin.Flag("clean", "Clean the histogram bar once its finished. Default is true").Default("true").NegatableBool()
|
||||||
|
|
||||||
url = kingpin.Arg("url", "request url").Required().String()
|
url = kingpin.Arg("url", "request url").Required().String()
|
||||||
)
|
)
|
||||||
|
@ -208,6 +208,6 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// terminal printer
|
// terminal printer
|
||||||
printer := NewPrinter(*requests, *duration, *notClearBar)
|
printer := NewPrinter(*requests, *duration, !*clean)
|
||||||
printer.PrintLoop(report.Snapshot, *interval, *seconds, report.Done())
|
printer.PrintLoop(report.Snapshot, *interval, *seconds, report.Done())
|
||||||
}
|
}
|
||||||
|
|
8
print.go
8
print.go
|
@ -32,11 +32,11 @@ type Printer struct {
|
||||||
pbInc int64
|
pbInc int64
|
||||||
pbNumStr string
|
pbNumStr string
|
||||||
pbDurStr string
|
pbDurStr string
|
||||||
notClearBar bool
|
noClean bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPrinter(maxNum int64, maxDuration time.Duration, notClearBar bool) *Printer {
|
func NewPrinter(maxNum int64, maxDuration time.Duration, noCleanBar bool) *Printer {
|
||||||
return &Printer{maxNum: maxNum, maxDuration: maxDuration, notClearBar: notClearBar}
|
return &Printer{maxNum: maxNum, maxDuration: maxDuration, noClean: noCleanBar}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) updateProgressValue(rs *SnapshotReport) {
|
func (p *Printer) updateProgressValue(rs *SnapshotReport) {
|
||||||
|
@ -221,7 +221,7 @@ func (p *Printer) buildHistogram(snapshot *SnapshotReport, useSeconds bool, isFi
|
||||||
if isFinal {
|
if isFinal {
|
||||||
row = append(row, fmt.Sprintf("%.2f%%", math.Floor(float64(bin.Count)*1e4/float64(hisSum)+0.5)/100.0))
|
row = append(row, fmt.Sprintf("%.2f%%", math.Floor(float64(bin.Count)*1e4/float64(hisSum)+0.5)/100.0))
|
||||||
}
|
}
|
||||||
if !isFinal || p.notClearBar {
|
if !isFinal || p.noClean {
|
||||||
barLen := 0
|
barLen := 0
|
||||||
if maxCount > 0 {
|
if maxCount > 0 {
|
||||||
barLen = (bin.Count*maxBarLen + maxCount/2) / maxCount
|
barLen = (bin.Count*maxBarLen + maxCount/2) / maxCount
|
||||||
|
|
Loading…
Reference in New Issue