Class: Mysqlknife::CLI
- Inherits:
-
Thor
- Object
- Thor
- Mysqlknife::CLI
- Defined in:
- lib/mysqlknife/cli.rb
Instance Method Summary collapse
- #command(conn = nil, host = nil, tool = nil) ⇒ Object
- #config(conn = nil) ⇒ Object
- #console(conn = nil, host = nil, database = nil) ⇒ Object
- #describe(conn = nil, host = nil, database = nil, table = nil) ⇒ Object
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #kill(conn = nil, host = nil) ⇒ Object
- #lag(conn = nil, host = nil) ⇒ Object
- #skip(conn = nil, host = nil) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(*args) ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mysqlknife/cli.rb', line 7 def initialize(*args) super @config = Configs.instance @mysql = MySQL.new @mysql_cmd = Mysql::Command.new @mysql_sql = Mysql::SQL.new @command = Command.new @parameters = Parameters.new $DEBUG = [:verbose] end |
Instance Method Details
#command(conn = nil, host = nil, tool = nil) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/mysqlknife/cli.rb', line 77 def command(conn = nil, host = nil, tool = nil) @parameters.connection = conn @parameters.host = host @parameters.tool = tool @parameters.connections @parameters.hosts @parameters.tools if @parameters.tool_selected @config.settings(conn) @config.mysql_host = @parameters.host @command.execute(@mysql_cmd.parse(@parameters.tool)) end end |
#config(conn = nil) ⇒ Object
20 21 22 23 24 |
# File 'lib/mysqlknife/cli.rb', line 20 def config(conn = nil) @parameters.connection = conn @parameters.connections @parameters.connection_details end |
#console(conn = nil, host = nil, database = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mysqlknife/cli.rb', line 31 def console(conn = nil, host = nil, database = nil) @parameters.connection = conn @parameters.host = host @parameters.connections @parameters.hosts if @parameters.host_selected @config.settings(conn) @config.mysql_host = @parameters.host @config.mysql_database = database @command.execute(@mysql_cmd.console([:execute])) end end |
#describe(conn = nil, host = nil, database = nil, table = nil) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mysqlknife/cli.rb', line 62 def describe(conn = nil, host = nil, database = nil, table = nil) @parameters.connection = conn @parameters.host = host @parameters.connections @parameters.hosts if @parameters.host_selected @config.settings(conn) @config.mysql_host = @parameters.host @command.execute(@mysql_cmd.describe(database, table)) end end |
#kill(conn = nil, host = nil) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/mysqlknife/cli.rb', line 109 def kill(conn = nil, host = nil) @parameters.connection = conn @parameters.host = host @parameters.connections @parameters.hosts if @parameters.host_selected @config.settings(conn) @config.mysql_host = @parameters.host @kill = Mysql::Kill.new @kill.where = [:where] if [:kill] @kill.clear else @kill.show end end end |
#lag(conn = nil, host = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mysqlknife/cli.rb', line 47 def lag(conn = nil, host = nil) @parameters.connection = conn @parameters.host = host @parameters.connections @parameters.slaves if @parameters.slave_selected @config.settings(conn) @config.mysql_host = @parameters.host @command.execute(@mysql_cmd.console(@mysql_sql.replica_lag)) end end |
#skip(conn = nil, host = nil) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/mysqlknife/cli.rb', line 142 def skip(conn = nil, host = nil) @parameters.connection = conn @parameters.host = host @parameters.connections @parameters.slaves if @parameters.slave_selected @config.settings(conn) @config.mysql_host = @parameters.host @replica = Mysql::Replica.new @replica.behind = [:behind] @replica.skip end end |
#version ⇒ Object
159 160 161 |
# File 'lib/mysqlknife/cli.rb', line 159 def version puts Mysqlknife::VERSION end |