Added --config option

This commit is contained in:
kojix2 2023-01-05 12:20:56 +09:00
parent 27a84a4df1
commit b1baa4073c
2 changed files with 23 additions and 18 deletions

View File

@ -40,24 +40,6 @@ module YouPlot
return
end
# config command
if @command == :config
if ENV['MYYOUPLOTRC']
puts "config file : #{ENV['MYYOUPLOTRC']}"
puts parser.config.inspect
else
puts <<~EOS
You don't have a config file. The default config file paths are:
./.youplot.yml, ./.youplotrc, ~/.youplot.yml, ~/.youplotrc
You can specify a config file with the environment variable MYYOUPLOTRC.
File format is YAML. For example:
width : 40
height : 20
EOS
end
return
end
# progressive mode
if options[:progressive]
stop = false

View File

@ -189,6 +189,7 @@ module YouPlot
colors color show the list of available colors
General options:
--config print config file info
--help print command specific help menu
--version print the version of YouPlot
MSG
@ -198,6 +199,10 @@ module YouPlot
main_parser.on('--help', 'print sub-command help menu') do
show_main_help
end
main_parser.on('--config', 'show config file info') do
show_config_info
end
end
def show_main_help(out = $stdout)
@ -206,6 +211,23 @@ module YouPlot
exit if YouPlot.run_as_executable?
end
def show_config_info
if ENV['MYYOUPLOTRC']
puts "config file : #{ENV['MYYOUPLOTRC']}"
puts config.inspect
else
puts <<~EOS
You don't have a config file. The default config file paths are:
./.youplot.yml, ./.youplotrc, ~/.youplot.yml, ~/.youplotrc
You can specify a config file with the environment variable MYYOUPLOTRC.
File format is YAML. For example:
width : 40
height : 20
EOS
end
exit if YouPlot.run_as_executable?
end
def sub_parser_add_symbol
sub_parser.on_head('--symbol STR', String, 'character to be used to plot the bars') do |v|
params.symbol = v
@ -339,6 +361,7 @@ module YouPlot
end
when :config
show_config_info
else
error_message = "uplot: unrecognized command '#{command}'"