Added configuration file paths and improved messages

This commit is contained in:
kojix2 2023-01-05 12:54:43 +09:00
parent 433c24e710
commit 654dbfca62

View File

@ -46,8 +46,12 @@ module YouPlot
paths << ENV['MYYOUPLOTRC'] if ENV['MYYOUPLOTRC'] paths << ENV['MYYOUPLOTRC'] if ENV['MYYOUPLOTRC']
paths << '.youplot.yml' paths << '.youplot.yml'
paths << '.youplotrc' paths << '.youplotrc'
paths << File.join(ENV['HOME'], '.youplotrc') if ENV['HOME'] if ENV['HOME']
paths << File.join(ENV['HOME'], '.youplot.yml') if ENV['HOME'] paths << File.join(ENV['HOME'], '.youplotrc')
paths << File.join(ENV['HOME'], '.youplot.yml')
paths << File.join(ENV['HOME'], '.config', 'youplot', 'youplotrc')
paths << File.join(ENV['HOME'], '.config', 'youplot', 'youplot.yml')
end
paths paths
end end
@ -217,12 +221,13 @@ module YouPlot
puts config.inspect puts config.inspect
else else
puts <<~EOS puts <<~EOS
You don't have a config file. The default config file paths are: Configuration file not found.
./.youplot.yml, ./.youplotrc, ~/.youplot.yml, ~/.youplotrc It should be a YAML file, like this example:
You can specify a config file with the environment variable MYYOUPLOTRC. width : 40
File format is YAML. For example: height : 20
width : 40 By default, YouPlot will look for the configuration file in these locations:
height : 20 #{config_file_candidate_paths.map { |s| ' ' + s }.join("\n")}
If you have the file elsewhere, you can specify its location with the `MYYOUPLOTRC` environment variable..
EOS EOS
end end
exit if YouPlot.run_as_executable? exit if YouPlot.run_as_executable?