lib/ardb/cli.rb in ardb-0.29.1 vs lib/ardb/cli.rb in ardb-0.29.2
- old
+ new
@@ -1,25 +1,30 @@
+# frozen_string_literal: true
+
require "ardb/cli/clirb"
require "ardb/cli/commands"
require "ardb/version"
module Ardb
class CLI
- COMMANDS = CommandSet.new{ |unknown| InvalidCommand.new(unknown) }.tap do |c|
- c.add(ConnectCommand)
- c.add(CreateCommand)
- c.add(DropCommand)
- c.add(GenerateMigrationCommand)
- c.add(MigrateCommand)
- c.add(MigrateUpCommand)
- c.add(MigrateDownCommand)
- c.add(MigrateForwardCommand)
- c.add(MigrateBackwardCommand)
- end
+ COMMANDS =
+ CommandSet.new{ |unknown|
+ InvalidCommand.new(unknown)
+ }.tap do |c|
+ c.add(ConnectCommand)
+ c.add(CreateCommand)
+ c.add(DropCommand)
+ c.add(GenerateMigrationCommand)
+ c.add(MigrateCommand)
+ c.add(MigrateUpCommand)
+ c.add(MigrateDownCommand)
+ c.add(MigrateForwardCommand)
+ c.add(MigrateBackwardCommand)
+ end
def self.run(args)
- self.new.run(args)
+ new.run(args)
end
def initialize(kernel = nil, stdout = nil, stderr = nil)
@kernel = kernel || Kernel
@stdout = stdout || $stdout
@@ -35,19 +40,19 @@
cmd.run(args)
rescue CLIRB::HelpExit
@stdout.puts cmd.command_help
rescue CLIRB::VersionExit
@stdout.puts Ardb::VERSION
- rescue CLIRB::Error, ArgumentError, InvalidCommandError => exception
- display_debug(exception)
- @stderr.puts "#{exception.message}\n\n"
+ rescue CLIRB::Error, ArgumentError, InvalidCommandError => ex
+ display_debug(ex)
+ @stderr.puts "#{ex.message}\n\n"
@stdout.puts cmd.command_help
@kernel.exit 1
rescue CommandExitError
@kernel.exit 1
- rescue StandardError => exception
- @stderr.puts "#{exception.class}: #{exception.message}"
- @stderr.puts exception.backtrace.join("\n")
+ rescue => ex
+ @stderr.puts "#{ex.class}: #{ex.message}"
+ @stderr.puts ex.backtrace.join("\n")
@kernel.exit 1
end
@kernel.exit 0
end