aboutsummaryrefslogtreecommitdiff
path: root/src/pomo.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pomo.rs')
-rw-r--r--src/pomo.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/pomo.rs b/src/pomo.rs
new file mode 100644
index 0000000..a5042ef
--- /dev/null
+++ b/src/pomo.rs
@@ -0,0 +1,27 @@
+use std::{ thread, time::Duration };
+
+pub struct Pomo {
+ pub time_remaining: Duration,
+}
+
+impl Pomo {
+ pub fn new() -> Self {
+ Self {
+ time_remaining: Duration::from_secs(25 * 60),
+ }
+ }
+
+ pub fn tick(&mut self) {
+ self.time_remaining -= Duration::from_secs(1);
+ }
+
+ pub fn run(&mut self) {
+ self.time_remaining = Duration::from_secs(10);
+ while self.time_remaining > Duration::from_secs(0) {
+ println!("{}", self.time_remaining.as_secs());
+ self.tick();
+ thread::sleep(Duration::from_secs(1));
+ }
+ println!("Done");
+ }
+}