Class: Mycmd::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/mycmd/cli.rb

Instance Method Summary collapse

Instance Method Details

#consoleObject



15
16
17
18
19
20
21
22
# File 'lib/mycmd/cli.rb', line 15

def console
  begin
    raise "mysql command not found" unless Kernel.system("which mysql > /dev/null")
    Kernel.system(Client.command)
  rescue => e
    puts e.message
  end
end

#query(sql) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/mycmd/cli.rb', line 25

def query(sql)
  begin
    Client.query(sql).print
  rescue => e
    puts e.message
  end
end

#tasks(task = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mycmd/cli.rb', line 35

def tasks(task=nil)
  if options[:list].nil?
    begin
      Client.execute_task(task).print
    rescue => e
      puts e.message
    end
  else
    conf = Configuration.new
    if conf.tasks.nil?
      puts "task is not registered"
    else
      conf.tasks.each{|k,v| puts "#{k}:\t#{v}"}
    end
  end
end