Class: Binpkgbot::Cli
- Inherits:
-
Object
- Object
- Binpkgbot::Cli
- Defined in:
- lib/binpkgbot/cli.rb
Instance Method Summary collapse
- #config ⇒ Object
- #config_path ⇒ Object
- #do_run ⇒ Object
- #do_version ⇒ Object
-
#initialize(argv) ⇒ Cli
constructor
A new instance of Cli.
- #options ⇒ Object
- #optparse ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Cli
Returns a new instance of Cli.
7 8 9 |
# File 'lib/binpkgbot/cli.rb', line 7 def initialize(argv) @argv = argv.dup end |
Instance Method Details
#config ⇒ Object
55 56 57 |
# File 'lib/binpkgbot/cli.rb', line 55 def config @config ||= Config.load_yaml(config_path) end |
#config_path ⇒ Object
51 52 53 |
# File 'lib/binpkgbot/cli.rb', line 51 def config_path [:config] || './binpkgbot.yml' end |
#do_run ⇒ Object
26 27 28 29 30 31 |
# File 'lib/binpkgbot/cli.rb', line 26 def do_run config.tasks.each do |task| task.execute end 0 end |
#do_version ⇒ Object
21 22 23 24 |
# File 'lib/binpkgbot/cli.rb', line 21 def do_version puts "binpkgbot #{Binpkgbot::VERSION}" 0 end |
#options ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/binpkgbot/cli.rb', line 33 def @options ||= { config: nil, mode: :run, debug: false, } end |
#optparse ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/binpkgbot/cli.rb', line 41 def optparse @optparse ||= OptionParser.new do |opt| opt.on('-v', '--version') { [:mode] = :version } opt.on('-c PATH', '--config PATH', 'config file to use (default: ./binpkgbot.yml)') do |file| [:config] = file end end end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/binpkgbot/cli.rb', line 11 def run optparse.parse!(@argv) case [:mode] when :version do_version when :run do_run end end |