Parent

Box::Command

Attributes

options[R]

Public Class Methods

run() click to toggle source

Initialize and run command.

# File lib/box/command.rb, line 10
def self.run
  new.run
end

Public Instance Methods

execute() click to toggle source
# File lib/box/command.rb, line 75
def execute
  types = options[:types]
  types = [ENV['BOX_TYPE'] || 'gz'] if types.empty?

  loc = ARGV.shift || Dir.pwd

  begin
    Box.package(loc, types, options)
  rescue => err
    raise err if $DEBUG
    $stderr.puts(err)
  end
end
parse() click to toggle source
# File lib/box/command.rb, line 18
def parse
  options = {:types=>[]}

  usage = OptionParser.new do |opt|

    opt.banner = "Usage: box [options] [path]\n" +
                 "Supported Types: zip gz gem"

    #opt.on('-c', '--create', "Create packages. This is default operation.") do
    #  options[:create] = true
    #end

    opt.on('-t', '--type [TYPE]', "Type of package (can be used more than once)") do |type|
      options[:types] << type
    end

    opt.on('-o', '--output [DIR]', "Where to save packages, defaults to current") do |output|
      options[:output] = output
    end

    opt.on('-m', '--manifest [FILE]', "Manifest file, defaults to MANIFEST{,.txt}") do |file|
      options[:manifest] = file
    end

    opt.on('-s', '--spec', "Save type specification to current directory, if applicable") do
      options[:spec] = true
    end

    opt.on('-q', '--quiet', "Surpress any non-essential output") do
      options[:quiet] = true
    end

    opt.on('--trial', "Turn on trial mode (no disk writes)") do
      $TRIAL = true
    end

    opt.on('--debug', "Turn on debug mode") do
      $DEBUG = true
    end

    opt.on_tail('-h', '--help', "Display this help message") do
      puts opt
      exit
    end

  end

  usage.parse!(ARGV)

  @options = options
end
run() click to toggle source
# File lib/box/command.rb, line 70
def run
  parse
  execute
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.