lib/phase/cli/deploy.rb in phase-0.0.14 vs lib/phase/cli/deploy.rb in phase-0.0.15

- old
+ new

@@ -1,33 +1,48 @@ module Phase module CLI class Deploy < Command command :deploy do |c| - c.syntax = "phase deploy <environment>" + c.syntax = "phase deploy [-e environment_name] version_number" + c.option "-e", "--env environment_name", String, "Deploy to this environment." + c.description = <<-EOS.strip_heredoc - Builds and deploys code to the specified <environment>. <environment> may be + Builds and deploys code to the specified 'environment_name'. 'environment_name' may be any environment configured in the Phasefile. EOS c.action do |args, options| new(args, options).run end end - attr_reader :environment + attr_reader :version_number def initialize(args, options) - @environment = args.first super + + @version_number = args.first + + fail "must specify environment with '-e'" unless options.env + fail "must specify version number" unless version_number end def run - if environment == "sandbox" - deployment = ::Phase::Deploy::SandboxDeployment.new + opts = { + version_tag: version_number + } + + deployment = case options.env + when "sandbox" + ::Phase::Deploy::SandboxDeployment.new(opts) + when "staging" + ::Phase::Deploy::StagingDeployment.new(opts) + when "production" + ::Phase::Deploy::ProductionDeployment.new(opts) else - deployment = ::Phase::Deploy::Deployment.new(environment) + fail "unknown environment: '#{environment}'" end deployment.execute! end