Sha256: ef6bd8f465089b305af70f90d6b886287f6d3b82d126b2ed48de74712a34637b

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

require 'trollop'

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

Usage:

heirloom list
heirloom versions -n NAME
heirloom show -n NAME -i VERSION
heirloom build -n NAME -i VERSION -d DIRECTORY [-p]
heirloom destroy -n NAME -i VERSION
EOS
        opt :help, "Display Help"
        opt :directory, "Source directory of artifact build.", :type => :string
        opt :id, "Id of artifact.", :type => :string
        opt :name, "Name of artifact.", :type => :string
        opt :public, "Is this artifact public?"
      end

      cmd = ARGV.shift
      a = Artifact.new :config => nil

      case cmd
      when 'list'
        puts a.list
      when 'versions', 'artifacts'
        puts a.versions :name => @opts[:name]
      when 'show'
        puts a.show(:name => @opts[:name],
                    :id => @opts[:id]).to_yaml
      when 'build'
        a.build :name => @opts[:name],
                :id => @opts[:id],
                :accounts => @opts[:accounts],
                :directory => @opts[:directory],
                :public => @opts[:public]
      when 'destroy', 'delete'
        a.destroy :name => @opts[:name],
                  :id => @opts[:id]
      else
        puts "Unkown command: '#{cmd}'."
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
heirloom-0.1.0 lib/heirloom/cli.rb
heirloom-0.0.9 lib/heirloom/cli.rb
heirloom-0.0.8 lib/heirloom/cli.rb