#!/usr/bin/env ruby require "acter" require "optparse" require "optparse/uri" require "pathname" schema_path = nil render_options = {} opt_parser = OptionParser.new do |opts| opts.version = Acter::VERSION opts.banner += "\n\nPerform HTTP requests defined by JSON schema\n\n" opts.on("-sPATH", "--schema=PATH", URI, "Path to JSON schema") do |v| schema_path = v.scheme ? v : Pathname.new(v.to_s) end opts.on("-H", "--[no-]show-headers", :OPTIONAL, TrueClass, "Output response headers (default: no)") do |v| render_options[:show_headers] = v end opts.on("-b", "--[no-]show-body", :OPTIONAL, TrueClass, "Output response body (default: yes)") do |v| render_options[:show_body] = v end opts.on("-c", "--[no-]color", :OPTIONAL, TrueClass, "Colorize output (default: only if output is a TTY)") do |v| render_options[:color] = v end opts.on("-h", "--help", "Help for subject or action") do Acter.help_wanted = true end opts.on("-V", "--version", "Version info") do puts opts.ver exit end end begin opt_parser.parse! rescue OptionParser::ParseError => e puts e puts opt_parser exit 1 end Acter.options_text = opt_parser.summarize Acter.run(ARGV, schema_path, render_options) or exit 1