As of now, the Requestor module only returns a response.body string.
It would be nice to have command line arguments such as --verbose / -v so treqs would return more information on the request such as status, headers, etc.
Here's an example of option parsing:
#!/usr/bin/env ruby
require 'optparse'
require 'treqs'
ARGV[0] = '--help' if ARGV.empty?
unless ARGV[0].include?('--') || ARGV[0].include?('-')
puts "invalid option: #{ARGV[0]}"
end
options = {}
opt_parser = OptionParser.new do |opt|
opt.on('--verbose', 'Shows all the request information') do |o|
options[:verbose] = o
end
opt.on('--option', 'Summary of this option') do |o|
options[:option] = o
end
end
begin
opt_parser.parse!
options.keys.each do |k|
case k
when :verbose
puts Treqs.call(verbose: true)
when :option
...
end
end
rescue StandardError => e
puts e
end
As of now, the Requestor module only returns a
response.bodystring.It would be nice to have command line arguments such as
--verbose/-vsotreqswould return more information on the request such as status, headers, etc.Here's an example of option parsing: