aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgoforthanddie.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/goforthanddie.rb b/goforthanddie.rb
index 176df46..e81d534 100755
--- a/goforthanddie.rb
+++ b/goforthanddie.rb
@@ -23,7 +23,7 @@ def handle(str, stack, markermode, markerautoclear, destructiveprint)
exit if str.nil?
str.split.each do |token|
case token
- when /[+-][0-9]+/
+ when /\A[+-]?[0-9]+\Z/
stack.push(token.to_i)
when "+", "add", "plus"
a, b = stack.pop(2)
@@ -141,6 +141,15 @@ def handle(str, stack, markermode, markerautoclear, destructiveprint)
getlist(stack, markermode, markerautoclear)
when "m", "mark"
stack.push(:mark)
+ when /\A'(.*)/
+ file = File.readlines(File.join(ENV['HOME'], ".goforthanddie"))
+ cmd = file.map { |line| line.split(?:) }.to_h[$1]
+ if cmd.nil?
+ puts "You haven't told me how to #{$1}!"
+ else
+ markermode, markerautoclear, destructiveprint =
+ handle(cmd, stack, markermode, markerautoclear, destructiveprint)
+ end
when "~s", "~stack"
puts stack.join(" ")
when "~mm", "~markermode"