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
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/gdocs-migration/cli.rb', line 26
def self.execute(stdout, arguments=[])
options = {
:from => nil,
:to => nil
}
mandatory_options = %w(from to)
parser = OptionParser.new do |opts|
opts.banner = <<-BANNER.gsub(/^ /,'')
GDocsMigration (http://github.com/chdorner/gdocs-migration)
Usage: #{File.basename($0)} [options]
Options are:
BANNER
opts.separator ""
opts.on("-f", "--from=FROM", String,
"The Google account to use as source.") { |arg| options[:from] = arg }
opts.on("-t", "--to=TO", String,
"The Google account to use as destination.") { |arg| options[:to] = arg }
opts.on("-h", "--help",
"Show this help message.") { stdout.puts opts; exit }
opts.parse!(arguments)
if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
stdout.puts opts; exit
end
end
from = options[:from]
to = options[:to]
migration = GDocsMigration::Migration.new from, to
migration.migrate
end
|