Sha256: 45c679d5b8da9b111927940eea132d56859ffbc51189003dcd6675e63d6c28be

Contents?: true

Size: 949 Bytes

Versions: 8

Compression:

Stored size: 949 Bytes

Contents

require 'getoptlong'

module Rebuild::CLI
  class RbldCommitCommand < Command
    def initialize
      @usage = "commit [OPTIONS] [ENVIRONMENT[:TAG]]"
      @description = "Commit environment modifications"
      @options = [["-t TAG,--tag TAG", "New tag to be created"]]
    end

    def parse_opts(parameters)
      replace_argv( parameters ) do
        opts = GetoptLong.new([ '--tag', '-t', GetoptLong::REQUIRED_ARGUMENT ])
        tag = nil
        opts.each do |opt, arg|
          case opt
            when '--tag'
              tag = arg
          end
        end

        raise "New tag not specified" unless tag
        Environment.validate_component( 'new tag', tag )
        return tag, ARGV
      end
    end

    def run(parameters)
      new_tag, parameters = parse_opts( parameters )

      env = Environment.new( parameters[0] )
      rbld_log.info("Going to commit #{env}")
      engine_api.commit!(env, new_tag)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rbld-1.3.2 cli/lib/commands/rbld_commit.rb
rbld-1.3.1 cli/lib/commands/rbld_commit.rb
rbld-1.3.0 cli/lib/commands/rbld_commit.rb
rbld-1.2.0 cli/lib/commands/rbld_commit.rb
rbld-1.1.0 cli/lib/commands/rbld_commit.rb
rbld-1.0.2 cli/lib/commands/rbld_commit.rb
rbld-1.0.1 cli/lib/commands/rbld_commit.rb
rbld-1.0.0 cli/lib/commands/rbld_commit.rb