Skip to content

Commit

Permalink
Change available command line options
Browse files Browse the repository at this point in the history
Replace:
- "quiet mode" by "verbose mode"
- "show offset" by "show date"
  • Loading branch information
danroc committed May 4, 2019
1 parent 2490bd0 commit 6bb6901
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions htp.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ const (
Second = 1000 * Millisecond
)

const UnixDateMilli = "02 Jan 2006 15:04:05.000 MST"
const unixDateMilli = "02 Jan 2006 15:04:05.000 MST"

func main() {
host := flag.String("u", "https://google.com", "Host URL")
count := flag.Uint("n", 8, "Number of requests")
quiet := flag.Bool("q", false, "Quiet mode (don't output offsets)")
adjust := flag.Bool("a", false, "Output offset to adjust time")
layout := flag.String("f", UnixDateMilli, "Time format layout")
verbose := flag.Bool("v", false, "Verbose mode (display offsets)")
showDate := flag.Bool("d", false, "Display date and time instead of offset")
dateLayout := flag.String("f", unixDateMilli, "Time format layout")
flag.Parse()

if strings.Index(*host, "://") == -1 {
Expand All @@ -48,7 +48,7 @@ func main() {
var (
t0, t1 int64
offset int64
sleep int64 = 0
sleep int64
lo int64 = math.MinInt64
hi int64 = math.MaxInt64
)
Expand Down Expand Up @@ -88,7 +88,7 @@ func main() {
}

offset = (hi + lo) / 2
if !*quiet {
if *verbose {
margin := (hi - lo) / 2
logger.Printf("offset: %+.3f (±%.3f) seconds\n",
toSec(offset), toSec(margin))
Expand All @@ -98,11 +98,11 @@ func main() {
sleep = mod(sleep, Second)
}

if *adjust {
fmt.Printf("%+.3f seconds\n", toSec(-offset))
} else {
if *showDate {
now := time.Now().Add(time.Duration(-offset))
fmt.Printf("%s\n", now.Format(*layout))
fmt.Printf("%s\n", now.Format(*dateLayout))
} else {
fmt.Printf("%+.3f seconds\n", toSec(-offset))
}
}

Expand Down

0 comments on commit 6bb6901

Please # to comment.