lib/ardb/cli.rb in ardb-0.28.3 vs lib/ardb/cli.rb in ardb-0.29.0
- old
+ new
@@ -1,19 +1,21 @@
-require 'ardb/cli/clirb'
-require 'ardb/cli/commands'
-require 'ardb/version'
+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, 'connect')
- c.add(CreateCommand, 'create')
- c.add(DropCommand, 'drop')
- c.add(MigrateCommand, 'migrate')
- c.add(GenerateMigrationCommand, 'generate-migration')
+ 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)
end
@@ -30,17 +32,17 @@
cmd_name = args.shift
cmd = COMMANDS[cmd_name]
cmd.run(args)
rescue CLIRB::HelpExit
- @stdout.puts cmd.help
+ @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"
- @stdout.puts cmd.help
+ @stdout.puts cmd.command_help
@kernel.exit 1
rescue CommandExitError
@kernel.exit 1
rescue StandardError => exception
@stderr.puts "#{exception.class}: #{exception.message}"
@@ -51,14 +53,12 @@
end
private
def display_debug(exception)
- if ENV['DEBUG']
+ if ENV["DEBUG"]
@stderr.puts "#{exception.class}: #{exception.message}"
@stderr.puts exception.backtrace.join("\n")
end
end
-
end
-
end