aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dbshell/client/mysql.rb
blob: 6cb8233213a46868007c4d5ff44e053f2b432ed8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module DBShell
  module Client
    class MySQL
      EXECUTABLE_NAME = 'mysql'

      def self.build_command(db_info)
        args = [EXECUTABLE_NAME]

        host = db_info['host']
        port = db_info['port']
        db_name = db_info['database']
        user = db_info['username']
        password = db_info['password']

        args.push("--user=#{user}") if user
        args.push("--password=#{password}") if password
        args.push("--host=#{host}") if host
        args.push("--port=#{port}") if port
        args.push(db_name)
      end
    end
  end
end