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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/centra/order_cli.rb', line 7
def self.parse!(name:, argv: ARGV)
options = {
centra_export_file: nil,
order_freq_output: nil,
anonymized_output: nil,
anonymize: true
}
OptionParser.new do |parser|
parser.banner = "Usage: #{name} [options]"
parser.default_argv = argv
parser.on("--centra-export=centra_orders.csv", String, "Path to Centra order export file (in CSV format).") do |value|
options[:centra_export_file] = value.strip
end
parser.on("--order-frequency-output=unique_emails.csv", String, "Path to output file.") do |value|
options[:order_freq_output] = value.strip
options[:order_freq_output] = "#{order_freq_output}.csv" unless value.end_with?(".csv")
end
parser.on("--anonymized-output=anonymized_orders.csv", String, "Path to output file.") do |value|
options[:anonymized_output] = value.strip
options[:anonymized_output] = "#{anonymized_output}.csv" unless value.end_with?(".csv")
end
parser.on("--[no-]anonymize", "Anonymize/scrub personal details.") do |value|
options[:anonymize] = value
end
CLIUtils.parse_order_filter_args!(parser, options)
parser.on("-h", "--help", "How to use") do
puts parser
exit
end
parser.on_tail('--version', 'Show version') do
puts "Centra version #{Centra::VERSION}"
exit
end
parser.on_tail("-h", "--help", "Show this message") do
puts parser
exit
end
end.parse!
centra_export_file = options[:centra_export_file]
if !centra_export_file || centra_export_file.empty?
puts "You must provide a Centra export file path."
puts "USAGE:"
puts " $ ruby #{name} --help"
exit 1
end
options
end
|