147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/mirrorworks.rb', line 147
def run(args)
begin
runtime_vars = {}
opts_msg = ''
OptionParser.new do |opts|
opts.banner = "Usage: mirrorworks [options] <command> [reflections]\n"
opts.banner += ' Options:'
opts.on('-V', '--version', 'print version and exit') {version}
opts.on('-h', '--help', 'print help and exit') {help(opts_msg)}
opts.on('-v', '--verbose', 'show rsync command when executing') do |v|
runtime_vars[:verbose] = v
end
opts.on('-x', '--hard', 'delete extra files on transfer') do |x|
runtime_vars[:hard] = x
end
opts_msg = opts.to_s
end.parse! args
help(opts_msg) if args.empty?
command = args.shift
parse_config unless command == 'setup'
case command
when 'push'
push args, runtime_vars
when 'pull'
pull args, runtime_vars
when 'status'
status args, runtime_vars
when 'list'
list args
when 'setup'
setup
else
raise "No command '#{command}'"
end
rescue Exception => e
puts e.message unless e.is_a? SystemExit
end
end
|