class Appraisal::CLI

def self.exit_on_failure?

def self.exit_on_failure?
  true
end

def self.help(shell, subcommand = false)

Override help command to print out usage
def self.help(shell, subcommand = false)
  shell.say strip_heredoc(<<-help)
    Appraisal: Find out what your Ruby gems are worth.
    Usage:
      appraisal [APPRAISAL_NAME] EXTERNAL_COMMAND
      If APPRAISAL_NAME is given, only run that EXTERNAL_COMMAND against the given
      appraisal, otherwise it runs the EXTERNAL_COMMAND against all appraisals.
  help
  if File.exist?('Appraisals')
    shell.say
    shell.say 'Available Appraisal(s):'
    AppraisalFile.each do |appraisal|
      shell.say "  - #{appraisal.name}"
    end
  end
  shell.say
  super
end

def self.strip_heredoc(string)

def self.strip_heredoc(string)
  indent = string.scan(/^[ \t]*(?=\S)/).min.size || 0
  string.gsub(/^[ \t]{#{indent}}/, '')
end

def clean

def clean
  FileUtils.rm_f Dir['gemfiles/*.{gemfile,gemfile.lock}']
end

def generate

def generate
  AppraisalFile.each do |appraisal|
    appraisal.write_gemfile
  end
end

def install

def install
  invoke :generate, [], {}
  AppraisalFile.each do |appraisal|
    appraisal.install(options)
    appraisal.relativize
  end
end

def list

def list
  AppraisalFile.new.appraisals.each { |appraisal| puts appraisal.name }
end

def method_missing(name, *args, &block)

def method_missing(name, *args, &block)
  matching_appraisal = AppraisalFile.new.appraisals.detect do |appraisal|
    appraisal.name == name.to_s
  end
  if matching_appraisal
    Command.new(args, :gemfile => matching_appraisal.gemfile_path).run
  else
    AppraisalFile.each do |appraisal|
      Command.new(ARGV, :gemfile => appraisal.gemfile_path).run
    end
  end
end

def update(*gems)

def update(*gems)
  invoke :generate, []
  AppraisalFile.each do |appraisal|
    appraisal.update(gems)
  end
end

def version

def version
  puts "Appraisal #{VERSION}"
end