Class: DbAgile::Command::SQL::Show

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

Overview

Display content of a table/view/query (shortcut for ‘export –text …’)

Usage: dba #DbAgile::Command#command_name [OPTIONS] DATASET

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

#category, #check_command, #command_name, #description, #execute_command, #initialize, #normalize_pending_arguments, #options, #run, #set_default_options, #show_help, #summary, #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

#add_options(opt) ⇒ Object

Contribute to options



13
14
15
16
17
18
19
20
# File 'lib/dbagile/command/sql/show.rb', line 13

def add_options(opt)
  opt.separator nil
  opt.separator "Options:"
  opt.on("--[no-]pretty",
         "Make/Avoid pretty output (truncate string at terminal size and so on.)") do |value|
    self.pretty = value
  end
end

#infer_options(argv) ⇒ Object

Infer options



23
24
25
26
27
28
29
30
31
# File 'lib/dbagile/command/sql/show.rb', line 23

def infer_options(argv)
  argv = ["--text"] + argv
  if argv.include?("--no-pretty")
    argv.delete("--no-pretty")
  else
    argv += ["--truncate-at", environment.console_width.to_s]
  end
  argv
end

#unsecure_run(requester_file, argv) ⇒ Object

Override to avoid pending options to be rejected



34
35
36
37
# File 'lib/dbagile/command/sql/show.rb', line 34

def unsecure_run(requester_file, argv)
  DbAgile::dba(environment){|dba| dba.bulk_export(infer_options(argv))}
  environment.output_buffer
end