Sha256: 308ecb4fa416a7e722856bf996837cc4e98b45d6c1d7e84879af03c08c363c4c
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
require 'dpl/error' require 'dpl/provider' module DPL class CLI def self.run(*args) new(args).run end OPTION_PATTERN = /\A--([a-z][a-z_\-]*)(?:=(.+))?\z/ attr_accessor :options def initialize(*args) options = {} args.flatten.each do |arg| next options.update(arg) if arg.is_a? Hash die("invalid option %p" % arg) unless match = OPTION_PATTERN.match(arg) key = match[1].tr('-', '_').to_sym if options.include? key options[key] = Array(options[key]) << match[2] else options[key] = match[2] || true end end self.options = default_options.merge(options) end def run provider = Provider.new(self, options) provider.deploy rescue Error => error options[:debug] ? raise(error) : die(error.message) end def default_options { :app => File.basename(Dir.pwd), :key_name => %x[hostname].strip } end def die(message) $stderr.puts(message) exit 1 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dpl-0.2.0 | lib/dpl/cli.rb |
dpl-0.1.0 | lib/dpl/cli.rb |