class Trooper::CLI
Attributes
argv[R]
command[R]
config[RW]
options[R]
Public Class Methods
new(argv)
click to toggle source
# File lib/trooper/cli.rb, line 16 def initialize(argv) @argv = argv @options = { :environment => :production } @command = option_parser.parse!(@argv)[0] if @command @command = @command.to_sym else raise CliArgumentError, "You didnt pass an action" end end
start(argv = ARGV)
click to toggle source
# File lib/trooper/cli.rb, line 7 def self.start(argv = ARGV) cli = self.new(argv) cli.execute cli end
Public Instance Methods
execute()
click to toggle source
# File lib/trooper/cli.rb, line 29 def execute case command when :init Configuration.init else config = Configuration.new(options) config.runner(command).execute end end
Private Instance Methods
option_parser()
click to toggle source
# File lib/trooper/cli.rb, line 41 def option_parser @option_parser ||= ::OptionParser.new do |op| op.banner = 'Usage: trooper <command> [options]' op.separator '' op.on "-d", "--debug", "Debug" do $trooper_log_level = ::Logger::DEBUG @options[:debug] = true end op.on "-e", "--env ENV", "Environment" do |e| @options[:environment] = e.to_sym end op.on "-f", "--file TROOPFILE", "Load a different Troopfile" do |f| @options[:file_name] = f || 'Troopfile' end op.on_tail "-h", "--help", "Help" do puts @option_parser exit end op.on_tail "-v", "--version", "Show version" do puts "Trooper v#{Trooper::Version::STRING}" exit end end end