Class: Mycmd::CLI
- Inherits:
-
Thor
- Object
- Thor
- Mycmd::CLI
- Defined in:
- lib/mycmd/cli.rb
Instance Method Summary collapse
Instance Method Details
#console ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mycmd/cli.rb', line 15 def console raise "mysql not found" unless Kernel.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 Kernel.system(cmd.join(" ")) end |
#query(sql) ⇒ Object
32 33 34 |
# File 'lib/mycmd/cli.rb', line 32 def query(sql) Client.query(sql).print end |
#tasks(task) ⇒ Object
37 38 39 |
# File 'lib/mycmd/cli.rb', line 37 def tasks(task) Client.execute_task(task).print end |