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