Sha256: b28ef294896aa117031fb7190069c908b62edfdc055a54f21eb444de9eceb875

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

#!/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("-S", "--[no-]show-status", :OPTIONAL, TrueClass, "Output response status code (default: yes)") do |v|
    render_options[:show_status] = v
  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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acter-0.2.0 exe/acter
acter-0.1.3 exe/acter
acter-0.1.2 exe/acter
acter-0.1.1 exe/acter