class Papers::CLI

Public Instance Methods

run() click to toggle source
# File lib/papers/cli.rb, line 7
def run
  options.parse!

  case @command
  when :generate
    Papers::ManifestGenerator.new.generate!
  when :update
    Papers::ManifestUpdater.new.update!
  when :help
    emit_help ""
  else
    emit_help "Unrecognized command."
  end
rescue Papers::FileExistsError => e
  warn "Error: 'papers_manifest.yml' already exists at '#{e.message}'. Aborting..."
rescue OptionParser::ParseError => e
  emit_help "Problem parsing options: #{e.message}"
end

Private Instance Methods

emit_help(header) click to toggle source
# File lib/papers/cli.rb, line 46
def emit_help(header)
  unless header.empty?
    puts header
    puts
  end
  puts options
end
options() click to toggle source
# File lib/papers/cli.rb, line 28
def options
  @options ||= OptionParser.new do |opts|
    opts.banner = 'Usage: papers [options]'

    opts.on('-g', '--generate', 'Generate papers_manifest.yml') do |v|
      @command = :generate
    end

    opts.on("-u", "--update", "Update papers_manifest.yml for Rubygems") do |v|
      @command = :update
    end

    opts.on('-h', '--help', 'Display this screen') do
      @command = :help
    end
  end
end