Skip to content

Commit

Permalink
fixed: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhav135 committed Sep 16, 2023
1 parent fb55188 commit 139323c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
25 changes: 11 additions & 14 deletions cmd/quiz/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,25 @@ import (
"github.com/vaibhav135/go-quiz-app/pkg/quiz/gui"
)


var startCmd = &cobra.Command{
Use: "start",
Short: "Start the quiz and check your skillz...",
Args: func(cmd *cobra.Command, args []string) error {
Args: func(cmd *cobra.Command, args []string) error {

return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
gui.Timer(3)
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
gui.Timer(3)

return nil
},
return nil
},
}

var timer, numberOfQuestions int
var timer int

func init() {
startCmd.Flags().IntVarP(&timer, "timer", "t", 1, "Timer for the quiz (time is in mins)")
startCmd.Flags().IntVarP(&timer, "totalQuestions", "q", 10, "Total no. of questions you want to have in the quiz")
startCmd.Flags().IntVarP(&timer, "timer", "t", 1, "Timer for the quiz (time is in mins)")
startCmd.Flags().IntVarP(&timer, "totalQuestions", "q", 10, "Total no. of questions you want to have in the quiz")

rootCmd.AddCommand(startCmd)
rootCmd.AddCommand(startCmd)
}


10 changes: 4 additions & 6 deletions pkg/quiz/gui/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (

var duration int
var prevElapsed = 0
var start = time.Now()
var start = time.Now()

func printRemainingTime(elapsed int) string {
timeRemaining := duration - elapsed
Expand All @@ -27,7 +27,7 @@ func printRemainingTime(elapsed int) string {
}

func drawTime(screen tcell.Screen, x int, y int, width int, height int) (int, int, int, int) {
elapsed := int(time.Now().Sub(start).Seconds())
elapsed := int(time.Since(start).Seconds())
if elapsed != prevElapsed {
prevElapsed = elapsed
}
Expand All @@ -43,10 +43,8 @@ func drawTime(screen tcell.Screen, x int, y int, width int, height int) (int, in
func refresh() {
tick := time.NewTicker(refreshInterval)
for {
select {
case <-tick.C:
app.Draw()
}
<-tick.C
app.Draw()
}
}

Expand Down

0 comments on commit 139323c

Please sign in to comment.