Class: Mycmd::CLI
- Inherits:
-
Thor
- Object
- Thor
- Mycmd::CLI
- Defined in:
- lib/mycmd/cli.rb
Instance Method Summary collapse
Instance Method Details
#console ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mycmd/cli.rb', line 13 def console raise "mysql not found" unless system("which mysql > /dev/null") conf = Configuration.new cmd = conf.to_hash.inject(["mysql"]) do |c,(k,v)| case k when :host then c << "-h#{v}" when :port then c << "-P#{v}" when :username then c << "-u#{v}" when :password then c << "-p#{v}" when :database then c << v end end system(cmd.join(" ")) end |
#query(sql) ⇒ Object
30 31 32 33 34 |
# File 'lib/mycmd/cli.rb', line 30 def query(sql) client = Configuration.connect printer = Printer.new(client.query(sql), true) printer.print end |
#tasks(task) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/mycmd/cli.rb', line 37 def tasks(task) config = Configuration.new client = config.connect printer = Printer.new(client.query(config.tasks[task.to_s]), true) printer.print end |