lib/timber/cli.rb in timber-2.0.24 vs lib/timber/cli.rb in timber-2.1.0.rc1

- old
+ new

@@ -1,47 +1,41 @@ require "optparse" require "yaml" -require "timber" - require "timber/cli/api" -require "timber/cli/application" -require "timber/cli/io_helper" -require "timber/cli/messages" +require "timber/cli/installers" +require "timber/cli/io" +require "timber/version" -require "timber/cli/install" - module Timber # @private class CLI AVAILABLE_COMMANDS = %w(install).freeze class << self attr_accessor :options def run(argv = ARGV) - @options = {} global = global_option_parser - commands = command_option_parser global.order!(argv) command = argv.shift - if command - if AVAILABLE_COMMANDS.include?(command) - commands[command].parse!(argv) - case command.to_sym - when :install - Timber::CLI::Install.run(argv.shift) - end - else - puts "Command '#{command}' does not exist, run timber -h to "\ - "see the help" - exit(1) - end - else + + case command + when nil # Print help puts global exit(0) + + when "install" + api_key = argv.shift + io = IO.new + Installers.run(api_key, io) + + else + puts "Command '#{command}' does not exist, run timber -h to "\ + "see the help" + exit(1) end end def global_option_parser OptionParser.new do |o| @@ -58,15 +52,9 @@ end o.separator "" o.separator "Available commands: #{AVAILABLE_COMMANDS.join(", ")}" end - end - - def command_option_parser - { - "install" => OptionParser.new - } end end end end \ No newline at end of file