class Binpkgbot::Cli

Public Class Methods

new(argv) click to toggle source
# File lib/binpkgbot/cli.rb, line 7
def initialize(argv)
  @argv = argv.dup
end

Public Instance Methods

config() click to toggle source
# File lib/binpkgbot/cli.rb, line 55
def config
  @config ||= Config.load_yaml(config_path)
end
config_path() click to toggle source
# File lib/binpkgbot/cli.rb, line 51
def config_path
  options[:config] || './binpkgbot.yml'
end
do_run() click to toggle source
# File lib/binpkgbot/cli.rb, line 26
def do_run
  config.tasks.each do |task|
    task.execute
  end
  0
end
do_version() click to toggle source
# File lib/binpkgbot/cli.rb, line 21
def do_version
  puts "binpkgbot #{Binpkgbot::VERSION}"
  0
end
options() click to toggle source
# File lib/binpkgbot/cli.rb, line 33
def options
  @options ||= {
    config: nil,
    mode: :run,
    debug: false,
  }
end
optparse() click to toggle source
# File lib/binpkgbot/cli.rb, line 41
def optparse
  @optparse ||= OptionParser.new do |opt|
    opt.on('-v', '--version') { options[:mode] = :version }

    opt.on('-c PATH', '--config PATH', 'config file to use (default: ./binpkgbot.yml)') do |file|
      options[:config] = file
    end
  end
end
run() click to toggle source
# File lib/binpkgbot/cli.rb, line 11
def run
  optparse.parse!(@argv)
  case options[:mode]
  when :version
    do_version
  when :run
    do_run
  end
end