Created
March 11, 2022 07:48
-
-
Save ChrisPritchard/0af94e1126ba1137f446894ebb7dfd68 to your computer and use it in GitHub Desktop.
pretty simple command line go pomodoro implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strings" | |
"time" | |
) | |
var reader = bufio.NewReader(os.Stdin) | |
func main() { | |
fmt.Printf( | |
"Ready for approx two hours of solid work!?\n" + | |
"During a pomodoro, remember: NO DISTRACTIONS\n" + | |
"Put everything off until the breaks.\n\n") | |
for true { | |
fmt.Println("Please enter I'M READY LET'S GO and press enter to begin:") | |
input, _ := reader.ReadString('\n') | |
if strings.TrimSpace(input) == "I'M READY LET'S GO" { | |
break | |
} | |
} | |
pomodoro(0) | |
takeABreak(false) | |
pomodoro(25) | |
takeABreak(false) | |
pomodoro(50) | |
takeABreak(false) | |
pomodoro(75) | |
fmt.Println("\nAll Done! Congratulations on 100 minutes of active time!") | |
} | |
func pomodoro(soFar int) { | |
fmt.Printf("Timer started, FOCUS FOCUS FOCUS!\n\n") | |
time.Sleep(5 * time.Minute) | |
fmt.Printf("%d minutes passed\n", soFar+5) | |
time.Sleep(5 * time.Minute) | |
fmt.Printf("%d minutes passed\n", soFar+10) | |
time.Sleep(5 * time.Minute) | |
fmt.Printf("%d minutes passed\n", soFar+15) | |
time.Sleep(5 * time.Minute) | |
fmt.Printf("%d minutes passed - last five to go\n", soFar+20) | |
time.Sleep(5 * time.Minute) | |
fmt.Println("Finished!") | |
} | |
func takeABreak(isLast bool) { | |
fmt.Printf( | |
"\nTake five minutes min to absorb what you have done,\n" + | |
"and to deal with any distractions, like email, texts or food/coffee.\n" + | |
"After five minutes you will be prompted to continue.\n\n") | |
time.Sleep(5 * time.Minute) | |
for true { | |
word := "next" | |
if isLast { | |
word = "final" | |
} | |
fmt.Printf("Please type LET'S CONTINUE and press enter to begin the %s pomodoro:\n", word) | |
input, _ := reader.ReadString('\n') | |
if strings.TrimSpace(input) == "LET'S CONTINUE" { | |
break | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment