class DPL::CLI
Constants
- OPTION_PATTERN
Attributes
fold_count[RW]
options[RW]
Public Class Methods
new(*args)
click to toggle source
# File lib/dpl/cli.rb, line 13 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.fold_count = 0 self.options = default_options.merge(options) end
run(*args)
click to toggle source
# File lib/dpl/cli.rb, line 6 def self.run(*args) new(args).run end
Public Instance Methods
default_options()
click to toggle source
# File lib/dpl/cli.rb, line 46 def default_options { :app => File.basename(Dir.pwd), :key_name => %x[hostname].strip } end
die(message)
click to toggle source
# File lib/dpl/cli.rb, line 57 def die(message) $stderr.puts(message) exit 1 end
env()
click to toggle source
# File lib/dpl/cli.rb, line 62 def env ENV end
fold(message) { || ... }
click to toggle source
# File lib/dpl/cli.rb, line 37 def fold(message) self.fold_count += 1 print "travis_fold:start:dpl.#{fold_count}\r" if options[:fold] puts "\e[33m#{message}\e[0m" yield ensure print "\ntravis_fold:end:dpl.#{fold_count}\r" if options[:fold] end
run()
click to toggle source
# File lib/dpl/cli.rb, line 30 def run provider = Provider.new(self, options) provider.deploy rescue Error => error options[:debug] ? raise(error) : die(error.message) end
shell(command)
click to toggle source
# File lib/dpl/cli.rb, line 53 def shell(command) system(command) end