Skip to content

Commit

Permalink
add xml option
Browse files Browse the repository at this point in the history
  • Loading branch information
cldwalker committed Jan 28, 2011
1 parent 36ae68c commit ebd1f49
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/wolf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ def browser_opens(uri)
end

def devour(argv=ARGV)
return puts('wolf [-o|--open] [-m|--menu] QUERY') if argv.empty?
return puts('wolf [-o|--open] [-m|--menu] [-x|--xml] QUERY') if argv.empty?
load_rc '~/.wolfrc'
options = {}
options[:open] = argv.delete('-o') || argv.delete('--open')
options[:menu] = argv.delete('-m') || argv.delete('--menu')
options[:xml] = argv.delete('-x') || argv.delete('--xml')
query = build_query(argv)
_devour(query, options)
end
Expand All @@ -43,6 +44,8 @@ def _devour(query, options={})
if options[:open]
browser_opens Wolfram.query(query,
:query_uri => "http://www.wolframalpha.com/input/").uri(:i => query)
elsif options[:xml]
puts Wolfram.fetch(query).xml
else
result = Wolfram.fetch(query)
puts render(result)
Expand Down

0 comments on commit ebd1f49

Please sign in to comment.