Class: CheckHTTP::CLI
- Inherits:
-
Object
- Object
- CheckHTTP::CLI
- Defined in:
- lib/check_http/cli.rb
Instance Method Summary collapse
Instance Method Details
#perform(url, opts = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/check_http/cli.rb', line 5 def perform(url, opts={}) if opts[:advanced] data = KV.parse(url) result = CheckHTTP.check(data['url'], data) puts KV.unparse(result) else result = CheckHTTP.check(url.strip) puts KV.unparse(result) end end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/check_http/cli.rb', line 16 def run opts = {} ARGV. do |o| o. = 'Usage: check_http [url]' o.set_summary_indent(' ') o.on('-a', '--advanced', 'enable advanced input mode') { opts[:advanced] = true } o.parse! if url = ARGV.shift perform(url, opts) else ARGF.each_line do |url| perform(url, opts) end end end end |