Last active
December 15, 2015 18:30
-
-
Save ZeroDragon/aaa13f71ca6d948aef33 to your computer and use it in GitHub Desktop.
The most useless script ever!
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
argsarr = process.argv[2..] | |
args = {} | |
for i,k in argsarr | |
if k%2 is 0 | |
args[i.replace(/--/,'')] = ~~argsarr[k+1] | |
log = (text)-> | |
if process.stdout | |
process.stdout.clearLine() | |
process.stdout.cursorTo 0 | |
process.stdout.write text | |
else | |
console.log text | |
class Brew | |
empty : true | |
content : 0 | |
size : 0 | |
refill : -> | |
@content = @size | |
@empty = false | |
drink : -> | |
@content-- | |
@empty = true if @content is 0 | |
constructor : (qty)-> | |
@size = qty | |
@refill() | |
cups = 1 | |
coffee = new Brew args.size | |
timer = setInterval -> | |
if coffee.empty | |
log "Time to get more coffee!!!" | |
cups++ | |
coffee.refill() | |
else | |
coffee.drink() | |
log "☕ x#{cups} Ahhh... warm coffee #{coffee.content}/#{coffee.size}" | |
,args.interval * 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run it with