Class: DbAgile::Command::Db::List

Inherits:
DbAgile::Command show all
Defined in:
lib/dbagile/command/db/list.rb

Overview

List available databases in current repository

Usage: dba #DbAgile::Command#command_name

Constant Summary

Constants inherited from DbAgile::Command

CATEGORIES, CATEGORY_NAMES

Instance Attribute Summary

Attributes inherited from DbAgile::Command

#environment

Attributes included from ClassMethods

#description, #summary, #usage

Instance Method Summary collapse

Methods inherited from DbAgile::Command

#add_options, #category, #check_command, #command_name, #description, #initialize, #normalize_pending_arguments, #options, #run, #set_default_options, #show_help, #summary, #unsecure_run, #usage

Methods included from ClassMethods

#build_command_options, #build_me, #category, #command_for, #command_name, #command_name_of, #each_subclass, #inherited, #ruby_method_for, #subclasses

Methods included from Robust

#ambigous_argument_list!, #assumption_error!, #bad_argument_list!, #has_command!, #is_in!, #valid_argument_list!, #valid_read_file!

Methods included from DbAgile::Core::IO::Robustness

#has_database!, #valid_database_name!, #valid_database_uri!, #valid_schema_files!

Constructor Details

This class inherits a constructor from DbAgile::Command

Instance Method Details

#execute_commandDbAgile::Core::Repository

Executes the command.

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dbagile/command/db/list.rb', line 17

def execute_command
  with_repository do |repository|

    unless repository.empty?
      flush("Available databases are (#{repository.friendly_path}):")
      repository.each do |database|
        msg = repository.current?(database) ? "  -> " : " "*5
        msg += database.name.to_s.ljust(15)
        msg += " "
        msg += database.uri
        flush(msg)
      end
    else
      say("No database found. Check #{repository.friendly_path}", :magenta)
    end

    repository
  end
end