class VCLog::CLI::Abstract

Abstract base class for all command classes.

Attributes

arguments[R]

Public Class Methods

inherited(subclass) click to toggle source
# File lib/vclog/cli/abstract.rb, line 30
def self.inherited(subclass)
  CLI.register << subclass
end
new() click to toggle source
# File lib/vclog/cli/abstract.rb, line 40
def initialize
  @options = {}
end
run(argv) click to toggle source
# File lib/vclog/cli/abstract.rb, line 18
def self.run(argv)
  new.run(argv)
rescue => err
  if $DEBUG
    raise err
  else
    puts err.message
    exit -1
  end
end
terms() click to toggle source
# File lib/vclog/cli/abstract.rb, line 35
def self.terms
  [name.split('::').last.downcase]
end

Public Instance Methods

options() click to toggle source
# File lib/vclog/cli/abstract.rb, line 45
def options
  @options
end
parser(&block) click to toggle source
# File lib/vclog/cli/abstract.rb, line 50
def parser(&block)
  parser = OptionParser.new(&block)

  parser.separator " "
  parser.separator "SYSTEM OPTIONS:"
  parser.on('--debug', 'show debugging information') do
    $DEBUG = true
  end
  parser.on('--help' , '-h', 'display this help information') do
    puts parser
    exit
  end
  parser
end
repo() click to toggle source

Repo is set in run.

# File lib/vclog/cli/abstract.rb, line 81
def repo
  @repo
end
run(argv=nil) click to toggle source

Run the command.

# File lib/vclog/cli/abstract.rb, line 66
def run(argv=nil)
  argv ||= ARGV.dup

  parser.parse!(argv)

  @arguments = argv

  root  = Dir.pwd  # TODO: find root

  @repo = VCLog::Repo.new(root, options)

  execute
end