Sha256: a5ed8f30daea6e663b9361f397bf11cb70652c65a6947d4d49288f82f082bb59

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

module Heirloom
  module CLI
    class Show

      def initialize
        @opts = read_options
        @logger = HeirloomLogger.new :log_level => @opts[:level]
        exit 1 unless CLI::Shared.valid_options? :provided => @opts,
                                                 :required => [:name],
                                                 :logger   => @logger
        id = @opts[:id] ? @opts[:id] : latest_id
        @archive = Archive.new :name   => @opts[:name],
                               :logger => @logger,
                               :id     => id
      end
      
      def show
        jj @archive.show
      end

      private

      def latest_id
        @archive = Archive.new :name => @opts[:name]
        @archive.list(1).first
      end

      def read_options
        Trollop::options do
          version Heirloom::VERSION
          banner <<-EOS

Show details about a version of an archive.

Usage:

heirloom show -n NAME -i ID

If -i is ommited, latest version is displayed.

EOS
          opt :help, "Display Help"
          opt :level, "Log level [debug|info|warn|error].", :type    => :string,
                                                            :default => 'info'
          opt :name, "Name of archive.", :type => :string
          opt :id, "id of the archive to display.", :type => :string
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
heirloom-0.3.1 lib/heirloom/cli/show.rb
heirloom-0.3.0 lib/heirloom/cli/show.rb
heirloom-0.3.0.rc1 lib/heirloom/cli/show.rb