Class: Mysqlknife::Parameter::Command

Inherits:
Base
  • Object
show all
Defined in:
lib/mysqlknife/parameter/command.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#connection, #host

Instance Method Summary collapse

Methods inherited from Base

#connections, #hosts, #initialize

Constructor Details

This class inherits a constructor from Mysqlknife::Parameter::Base

Instance Attribute Details

#cmd=(value) ⇒ Object (writeonly)

Sets the attribute cmd

Parameters:

  • value

    the value to set the attribute cmd to.



6
7
8
# File 'lib/mysqlknife/parameter/command.rb', line 6

def cmd=(value)
  @cmd = value
end

Instance Method Details

#commandsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mysqlknife/parameter/command.rb', line 8

def commands
  if @connection.nil? == false &&
     @host.nil?       == false &&
     @cmd.nil?
    puts "Commands:"
    if @config.commands.nil? == false &&
       @config.commands.count > 0 &&
       @config.commands.is_a?(Array)
      @config.commands.each do |command|
        puts " - #{command}"
      end
    end
  end
end

#connectObject



23
24
25
26
27
28
29
30
31
# File 'lib/mysqlknife/parameter/command.rb', line 23

def connect
  if @connection.nil? == false &&
     @host.nil?       == false &&
     @cmd.nil?        == false
    @config.connection(@connection)
    puts "Connecting to: #{@config.select(@host)}"
    @command.execute(@mysql.parse(@config.command(@cmd)))
  end
end