Sha256: 7efba624925f3f9880c776ff4509b7690069cf58f19f0c2e28ffb4c05b36b16e

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require 'trollop'

module Heirloom
  module CLI
    def self.start
      @opts = Trollop::options do
        banner <<-EOS
build and manage artifacts

Usage:

heirloom list
heirloom build [options]
heirloom delete [options]
heirloom info [options]
EOS
        opt :help, "Display Help"
        opt :accounts, "CSV list of accounts to authorize", :type => :string
        opt :class, "Class of artifact.  This should match the SCM repo", :type => :string
        opt :dir, "Directory which contains git repo", :type => :string
        opt :prefix, "Bucket prefix", :type => :string
        opt :sha, "Git Sha", :type => :string
      end

      cmd = ARGV.shift

      case cmd
      when 'build'
        raise 'Missing required args' unless @opts[:sha] && @opts[:class]
        h = Heirloom.new :heirloom_type => @opts[:class],
                         :source_dir => @opts[:dir] ||= ".",
                         :prefix => @opts[:prefix],
                         :accounts => @opts[:accounts].split(',')

        h.build_and_upload_to_s3(:sha => @opts[:sha])
      when 'list'
        Heirloom.list.each do |a|
          puts a.to_yaml
        end
      when 'info'
        raise 'Missing required args' unless @opts[:sha] && @opts[:class]
        puts Heirloom.info(:class => @opts[:class], :sha => @opts[:sha]).to_yaml
      when 'delete'
        raise 'Missing required args' unless @opts[:sha] && @opts[:class]
        puts Heirloom.delete(:class => @opts[:class], :sha => @opts[:sha]).to_yaml
        puts "!!Make sure to manualy delete any artifacts from S3!!!"
      else
        puts "Unkown command: '#{cmd}'."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.0.2 lib/heirloom/cli.rb