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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/highrise_assist/runner.rb', line 19
def run!
parser = OptionParser.new do |o|
o.banner = "Usage: #{$0} COMMAND [options]"
o.separator ""
o.separator "Commands:"
o.separator " * export - export next highrise items:"
%w(cases deals people companies emails notes comments attachments).each do |item|
o.separator " * #{item}"
end
o.separator ""
o.separator "Common options:"
o.on("--domain DOMAIN", "highrise subdomain or full domain name") { |v| set_domain_option(v) }
o.on("--token TOKEN", "highrise API authentication token") { |v| @options[:token] = v }
o.separator ""
o.separator "Export options:"
o.on("--tag TAG", "filter items with given tag name") { |v| @options[:tag] = v }
o.on("--directory DIRECTORY", "working directory") { |v| @options[:directory] = v }
o.on("--format FORMAT", "data format (#{Command::Export::FORMATS.join(',')}) ") { |v| @options[:format] = v }
o.on("--skip-attachments", "don't download attachments") { @options[:skip_attachments] = true }
o.on("--skip-cases", "don't export cases") { @options[:skip_items] << "Kase" }
o.on("--skip-deals", "don't export deals") { @options[:skip_items] << "Deal" }
o.on("--skip-notes", "don't export notes") { @options[:skip_items] << "Note" }
o.on("--skip-emails", "don't export emails") { @options[:skip_items] << "Email" }
o.on("--skip-comments", "don't export comments") { @options[:skip_items] << "Comment" }
o.separator ""
o.separator "Misc options:"
o.on_tail("-h", "--help", "Show this message") { puts o; exit }
o.on_tail('-v', '--version', "Show version") { puts HighriseAssist::VERSION; exit }
end
parser.parse!(@argv)
command = @argv.first
Command.defined?(command) or raise OptionParser::ParseError, "Unknown command #{command.inspect}"
Command.run(command, @options)
rescue OptionParser::ParseError => e
warn e.message
puts parser.help
exit 1
end
|