thes/exe/thes

21 lines
268 B
Ruby
Executable File

#!/usr/bin/env ruby
require 'thes'
query = ARGV.join(' ').strip
if query.length.zero?
puts 'Usage: thes <search term>'
exit 1
end
result = Thes.new(query).call
if $stdout.isatty
IO.popen('less', 'w') { |f| f << result }
else
$stdout << result
end
exit 0