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
51
52
|
# File 'lib/devilicious/config.rb', line 6
def self.parse(args)
config = OpenStruct.new
config.debug = false
config.verbose = false
config.formatter = "Verbose"
config.max_volume = BigDecimal.new("10")
config.min_volume = BigDecimal.new("0.1")
config.beep_profit_threshold = BigDecimal.new("-1") config.default_fiat_currency = "EUR" config.market_refresh_rate = 30 config.min_profit = 1
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: devilicious [config]"
opts.separator ""
opts.on("-f", "--formatter TYPE", Formatter.list.keys,
"Select formatter (#{Formatter.list.keys.sort.join(", ")})") do |f|
config.formatter = f
end
opts.on("-m", "--max-volume N", "Maximum volume to trade") do |m|
config.max_volume = BigDecimal.new(m)
end
opts.on("-b", "--beep-profit-threshold N", "Beep the fuck out of the speakers when profit threshold is reached") do |t|
config.beep_profit_threshold = BigDecimal.new(t)
end
opts.on("-v", "--verbose", "Run verbosely") do |v|
config.verbose = v
end
opts.on("-d", "--debug", "Debug mode") do |d|
config.debug = d
end
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
end
opt_parser.parse!(args)
config.freeze
end
|