lib/phase/cli/deploy.rb in phase-1.0.1 vs lib/phase/cli/deploy.rb in phase-1.0.2

- old
+ new

@@ -1,40 +1,40 @@ module Phase module CLI class Deploy < Command command :deploy do |c| - c.syntax = "phase deploy <instance_role> [-n version_number]" + c.syntax = "phase deploy <environment_name> <version_number>" - c.option "-n", "--number", String, "Specific version number to deploy." - c.description = <<-EOS.strip_heredoc - Builds and deploys code to instance with the specified <instance_role> in their - "Role" tags. Deploys the current version (in the file set via - `config.deploy.version_lockfile`) unless an alternate version is provided with the - -n option. + Builds and deploys code to the specified <environment_name>, which may be + any environment configured in the Phasefile. EOS c.action do |args, options| - options.default(number: ::Phase::Deploy::Version.current) new(args, options).run end end - attr_reader :instance_role + attr_reader :env_name, :version_number def initialize(args, options) super - fail "Must specify 'instance_role' name" if args.first.blank? - @instance_role = args.first + fail "must specify both environment and version number" unless args.count >= 2 + + @env_name = args[0] + @version_number = args[1] + + fail "must specify environment" unless env_name + fail "must specify version number" unless version_number end def run - # environment = config.deploy.environments.find { |e| e.name == instance_role } - # fail "unknown environment: '#{instance_role}'" unless environment + environment = config.deploy.environments.find { |e| e.name == env_name } + fail "unknown environment: '#{env_name}'" unless environment - deployment = ::Phase::Deploy::Deployment.new(instance_role, options.number) + deployment = Deploy::Deployment.new(environment, version_tag: version_number) deployment.execute! end end end