Skip to content

Commit

Permalink
Timer command. (Doesn't work.)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeorr committed Nov 29, 2021
1 parent c50b808 commit f308031
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions unfinished/timer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python
"""A simple timer."""

import argparse
import time

def get_parser():
parser = argparse.ArgumentParser()
parser.description = __doc__.splitlines()[0]
paa = parser.add_argument
paa("minutes", type=int)
return parser

def main():
parser = get_parser()
opts = parser.parse_args()
start = time.time()
throttle = 10.0 # Update status every N seconds.
while True:
now = time.time()
remaining = start - now
if remaining < 1.0:
break
print(int(remaining), "minutes remaining.")
time.sleep(throttle)
print("Beep!\a")

if __name__ == "__main__": main()

0 comments on commit f308031

Please sign in to comment.