bin/balboa in balboa-0.1.2 vs bin/balboa in balboa-0.1.3

- old
+ new

@@ -1,26 +1,36 @@ #!/usr/bin/env ruby # frozen_string_literal: true require_relative '../lib/balboa' -command = ARGV.shift || :help -app = Balboa::CLI::Application.new(command) -options = Balboa::CLI::Options.parse(ARGV) +defaults = if File.exist?(Balboa::CONFIG_FILE) + YAML.load_file(Balboa::CONFIG_FILE) +else + Balboa::CLI::Defaults.prompt +end -raw_interactor = Balboa::Interactor::CapybaraInteractor.new +options = Balboa::CLI::Options.parse(ARGV, defaults) -Balboa::Interactor::InteractorBuilder.create(raw_interactor, options) - +raw_interactor = Balboa::Interactor::InteractorBuilder.create(options) interactor = Balboa::Interactor::InteractorWrapper.new(raw_interactor) app_last = Balboa::CLI::Command::LastCommand.new(interactor) -app_punch = Balboa::CLI::Command::PunchCommand.new(interactor, options['holidays']) -app_help = Balboa::CLI::Command::HelpCommand.new +app_punch = Balboa::CLI::Command::PunchCommand.new(interactor) +app_reset = Balboa::CLI::Command::ResetCommand.new app_star_wars = Balboa::CLI::Command::StarWarsCommand.new +command = ARGV.first +app = Balboa::CLI::Application.new(command) app.add_command(:last, app_last) app.add_command(:punch, app_punch) -app.add_command(:help, app_help) +app.add_command(:reset, app_reset) app.add_command(:star_wars, app_star_wars) -app.execute +begin + app.execute +rescue Balboa::CLI::Application::CommandNotFound + $stdout.puts("\nCommand Not Found!") + $stdout.puts("\nRun `balboa -h' to check available commands and options.") +rescue Balboa::Interactor::Command::LoginCommand::LoginFailure + $stdout.puts("\nWrong e-mail or password!") +end