lib/qcmd/cli.rb in qcmd-0.1.12 vs lib/qcmd/cli.rb in qcmd-0.1.13
- old
+ new
@@ -300,10 +300,12 @@
def handle_input args
command = args[0].to_s
Qcmd.debug "[CLI handle_input] command: #{ command }; args: #{ args.inspect }"
+ # this is where qcmd decides how to handle user input
+
case command
when 'exit', 'quit', 'q'
print 'exiting...'
exit 0
@@ -491,9 +493,18 @@
end
else
log(:warning, "The select command should be in the form `select CUE_NUMBER`.")
end
+ # local ruby commands
+ when 'sleep'
+ if args.size != 2
+ log(:warning, "The sleep command expects one argument")
+ elsif !(args[1].is_a?(Fixnum) || args[1].is_a?(Float))
+ log(:warning, "The sleep command expects a number")
+ else
+ sleep args[1].to_f
+ end
else
if aliases[command]
Qcmd.debug "[CLI handle_input] using alias #{ command }"
new_expression = expand_alias(command, args)