lib/employ/cli.rb in employ-0.0.1 vs lib/employ/cli.rb in employ-0.0.2

- old
+ new

@@ -1,10 +1,35 @@ -require 'employ/cli/promote' - module Employ class CLI < Thor - class_option :verbose, type: :boolean + class_option :verbose, type: :boolean, aliases: :v - include Employ::CLI::Promote + class_option 'assume-yes', type: :boolean, aliases: %w(y yes), + desc: 'Automatic yes to prompts' + + desc 'promote <env>', 'promotes commit to <env>' + long_desc "TODO" + option :interactive, type: :boolean, aliases: :i + def promote(env) + unless options['assume-yes'] || yes?('Are you sure?') + puts 'Nothing done. Bye!' + exit 1 + end + + if options[:interactive] + last_tag = Git.last_tag(env) + puts "last tag: #{last_tag}" if options[:verbose] + # TODO + else + name = Git.tag!(env) + puts "New tag promoted: #{name}" if options[:verbose] + end + end + + desc 'rollback <env>', 'rollbacks <env> tag to the penultimate one' + long_desc "TODO" + def rollback(env) + penultimate_tag = Git.penultimate_tag(env) + Git.retag! env, penultimate_tag + end end end