bin/dude
#!/usr/bin/env ruby
require 'the_dude'
# Load rc files from home directory and local directory
TheDude::Dsl.from_file "#{ENV['HOME']}/.duderc"
TheDude::Dsl.from_file '.duderc'
# Setup rlwrap for readline support
if ARGV.include? '-i'
interactive_mode = true
if !ENV['__REPL_WRAPPED'] && system("which rlwrap > /dev/null 2> /dev/null")
ENV['__REPL_WRAPPED'] = '0'
exec "rlwrap #{Shellwords.escape(__FILE__)} #{ARGV.join(' ')}"
end
end
question = ARGV.join(' ')
if interactive_mode
loop do
print "dude, "
begin
question = $stdin.gets.chomp
rescue NoMethodError, Interrupt
exit
end
puts TheDude.ask question
puts ''
end
else
puts TheDude.ask question
end