mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-05 22:31:11 +08:00
Added config option to allow configuration files to be specified later
This commit is contained in:
parent
8eca14a70d
commit
26050a2f87
@ -29,12 +29,10 @@ module YouPlot
|
|||||||
)
|
)
|
||||||
|
|
||||||
@params = Parameters.new
|
@params = Parameters.new
|
||||||
|
|
||||||
apply_config_file
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_config_file
|
def apply_config_file
|
||||||
return unless find_config_file
|
return if !config_file && find_config_file.nil?
|
||||||
|
|
||||||
read_config_file
|
read_config_file
|
||||||
configure
|
configure
|
||||||
@ -79,9 +77,9 @@ module YouPlot
|
|||||||
config.each do |k, v|
|
config.each do |k, v|
|
||||||
k = k.to_sym
|
k = k.to_sym
|
||||||
if option_members.include?(k)
|
if option_members.include?(k)
|
||||||
@options[k] = v
|
@options[k] ||= v
|
||||||
elsif param_members.include?(k)
|
elsif param_members.include?(k)
|
||||||
@params[k] = v
|
@params[k] ||= v
|
||||||
else
|
else
|
||||||
raise Error, "Unknown option/param: #{k}"
|
raise Error, "Unknown option/param: #{k}"
|
||||||
end
|
end
|
||||||
@ -162,6 +160,9 @@ module YouPlot
|
|||||||
puts parser.help
|
puts parser.help
|
||||||
exit if YouPlot.run_as_executable?
|
exit if YouPlot.run_as_executable?
|
||||||
end
|
end
|
||||||
|
parser.on('--config FILE', 'specify a config file') do |v|
|
||||||
|
@config_file = v
|
||||||
|
end
|
||||||
parser.on('--debug', TrueClass, 'print preprocessed data') do |v|
|
parser.on('--debug', TrueClass, 'print preprocessed data') do |v|
|
||||||
options[:debug] = v
|
options[:debug] = v
|
||||||
end
|
end
|
||||||
@ -394,6 +395,8 @@ module YouPlot
|
|||||||
warn "uplot: #{e.message}"
|
warn "uplot: #{e.message}"
|
||||||
exit 1 if YouPlot.run_as_executable?
|
exit 1 if YouPlot.run_as_executable?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
apply_config_file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user