Class: PgSync::Client

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/pgsync/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#colorize, #config_file, #db_config_file, #log, #search_tree

Constructor Details

#initialize(args) ⇒ Client

Returns a new instance of Client.



5
6
7
8
# File 'lib/pgsync/client.rb', line 5

def initialize(args)
  @args = args
  $stderr.sync = true
end

Class Method Details

.startObject



28
29
30
# File 'lib/pgsync/client.rb', line 28

def self.start
  new(ARGV).perform(testing: false)
end

Instance Method Details

#perform(testing: true) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pgsync/client.rb', line 10

def perform(testing: true)
  opts = parse_args

  if opts.version?
    log VERSION
  elsif opts.help?
    log opts
  # TODO remove deprecated conditions (last two)
  elsif opts.init? || opts.setup? || opts.arguments[0] == "setup"
    Init.new.perform(opts)
  else
    Sync.new.perform(opts)
  end
rescue Error, PG::ConnectionBad => e
  raise e if testing
  abort colorize(e.message, 31) # red
end