mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-05 22:31:11 +08:00
Added --config option
This commit is contained in:
parent
27a84a4df1
commit
b1baa4073c
@ -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
|
||||
|
@ -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}'"
|
||||
|
Loading…
Reference in New Issue
Block a user