6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/quicksync/cli.rb', line 6
def self.run
$logger.debug "CLI.run: function called"
qsync = QuickSync::RSync.new
config = $default_options
from = {}
to = {}
options={}
settings = {}
copy_strategy = :push_to;
ui.choose do ||
.prompt = "Copy strategy? "
copy_strategy = .choices(:pull_from, :push_to)
end
from[:dir] = ui.ask("from[:dir]? ") { |q| q.default = config[:from][:dir] }
from[:host] = ui.ask("from[:host]? ") { |q| q.default = config[:from][:host] }
from[:user] = ui.ask("from[:user]? ") { |q| q.default = config[:from][:user] }
to[:dir] = ui.ask("to[:dir]? ") { |q| q.default = config[:to][:dir] }
to[:host] = ui.ask("to[:host]? ") { |q| q.default = config[:to][:host] }
to[:user] = ui.ask("to[:user]? ") { |q| q.default = config[:to][:user] }
options[:include] = ui.ask("includes? ", lambda { |str| str.split(/,\s*/) }) { |q| q.default = config[:include].join(',')}
options[:exclude] = ui.ask("excludes? ", lambda { |str| str.split(/,\s*/) }) { |q| q.default = config[:exclude].join(',') }
options[:copy_options] = ui.ask("copy options? ", lambda { |str| str.split(/,\s*/) }) { |q| q.default = config[:copy_options].join(',') }
config[:settings].each do |key, value|
settings[key.to_sym] = ui.ask("settings[#{key.to_s}]? ") { |q| q.default = "#{value}" }
end
options[:settings] = settings
$logger.debug "CLI.run from=#{from}"
$logger.debug "CLI.run to=#{to}"
$logger.debug "CLI.run copy_options=#{options[:copy_options]}"
$logger.debug "CLI.run include=#{options[:include]}"
$logger.debug "CLI.run exclude=#{options[:exclude]}"
$logger.debug "CLI.run settings=#{options[:settings]}"
qs = QuickSync::RSync.new
cmd = qs.pull_from(from,to,options)
$logger.important "CLI.run: pull_from cmd=#{cmd}"
end
|