Class: Ardb::CLI::DropCommand

Inherits:
Object
  • Object
show all
Includes:
ValidCommand
Defined in:
lib/ardb/cli/commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.command_nameObject



120
# File 'lib/ardb/cli/commands.rb', line 120

def self.command_name;    "drop";                   end

.command_summaryObject



121
# File 'lib/ardb/cli/commands.rb', line 121

def self.command_summary; "Drop the configured DB"; end

Instance Method Details

#run(argv, *args) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/ardb/cli/commands.rb', line 123

def run(argv, *args)
  super

  begin
    Ardb.init(true)
    Ardb.adapter.drop_db
    @stdout.puts "dropped #{Ardb.config.adapter} db #{Ardb.config.database.inspect}"
  rescue ActiveRecord::NoDatabaseError => e
    @stderr.puts "error: database #{Ardb.config.database.inspect} "\
                 "does not exist"
  rescue StandardError => e
    @stderr.puts e
    @stderr.puts "error dropping #{Ardb.config.database.inspect} database"
    raise CommandExitError
  end
end