Class: Organo::CLI::Commands::Dump

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/organo/commands/dump.rb

Instance Method Summary collapse

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/organo/commands/dump.rb', line 12

def call(*)
  executable = 'sqlite3'
  can_run = false
  win_filepath = "#{File.expand_path('~')}/sqlite-tools/sqlite3.exe"
  if OS.windows? && File.exist?(win_filepath)
    executable = win_filepath
    can_run = true
  elsif OS.linux? && system("which #{executable}")
    can_run = true
  end
  output = 'Unable to run the command.'
  output = `#{executable} #{Config::DATABASE_FILE} .dump > organo_dump.sql` if can_run
  puts output unless output.empty?
end