Parent

Heroku::Kensa::Client::OptParser

Constants

KNOWN_ARGS

OptionParser errors out on unnamed options so we have to pull out all the –flags and –flag=somethings

Public Class Methods

defaults() click to toggle source
# File lib/heroku/kensa/client.rb, line 265
def self.defaults
  {
    :filename => 'addon-manifest.json',
    :env      => "test",
    :async    => false,
  }
end
parse(args) click to toggle source
# File lib/heroku/kensa/client.rb, line 261
def self.parse(args)
  defaults.merge(self.parse_options(args))
end
parse_command_line(args) click to toggle source
# File lib/heroku/kensa/client.rb, line 295
def self.parse_command_line(args)
  {}.tap do |options|
    OptionParser.new do |o|
      o.on("-f file", "--filename") { |filename| options[:filename] = filename }
      o.on("--async")           { options[:async] = true }
      o.on("--production")      { options[:env] = "production" }
      o.on("--without-sso")     { options[:sso] = false }
      o.on("-h", "--help")      { command = "help" }
      o.on("-p plan", "--plan") { |plan| options[:plan] = plan }
      o.on("-v", "--version")   { options[:command] = "version" }
      o.on("-s sso", "--sso")   { |method| options[:method] = method }
      o.on("--foreman")         { options[:foreman] = true }
      o.on("-t name", "--template") do |template|
        options[:template] = template
      end
      #note: have to add these to KNOWN_ARGS

      begin
        o.parse!(args)
      rescue OptionParser::InvalidOption => e
        raise CommandInvalid, e.message
      end
    end
  end
end
parse_provision(flags, args) click to toggle source
# File lib/heroku/kensa/client.rb, line 281
def self.parse_provision(flags, args)
  {}.tap do |options|
    flags.each do |arg|
      key, value = arg.split('=')
      unless value
        peek = args[args.index(key) + 1]
        value = peek && !peek.match(/^--/) ? peek : 'true'
      end
      key = key.sub(/^--/,'')
      options[key] = value 
    end
  end
end
pre_parse(args) click to toggle source
# File lib/heroku/kensa/client.rb, line 275
def self.pre_parse(args)
  args.partition do |token| 
    token.match(/^--/) && !token.match(/^--(#{KNOWN_ARGS.join('|')})/)
  end.reverse
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.