Skip to content
This repository has been archived by the owner on Mar 24, 2019. It is now read-only.

Commit

Permalink
Animated grade-polling timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Xie committed Dec 27, 2018
1 parent 8e1efab commit 45d6888
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions cmd/grades.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ check:
interval := time.Duration(rng.Int63n(int64(gradesMaxPollInterval-
gradesMinPollInterval))) + gradesMinPollInterval

interact.Errf("Checking again in %.f seconds (press ctrl-c to stop).\n",
interval.Seconds())
time.Sleep(interval)
for interval >= 0 {
interact.Errf("\rChecking again in %.f seconds (press ctrl-c to stop).",
interval.Seconds())
time.Sleep(time.Second)
interval -= time.Second
}
interact.Errln()
goto check
}
return nil
Expand Down
6 changes: 4 additions & 2 deletions cmd/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ func interactiveHelp() {
}

// Add custom entries:
entries = append(entries, HelpEntry{"poll", "Poll grades repeatedly, every " +
"30s."})
entries = append(entries, HelpEntry{
"poll",
gradesCmd.GetFlag("poll").Model().Help,
})
entries = append(entries, HelpEntry{"quit", "Quit interactive mode."})

fmt.Println("Commands:")
Expand Down

0 comments on commit 45d6888

Please sign in to comment.