diff --git a/lib/youplot/command.rb b/lib/youplot/command.rb index ac4c281..28ad50e 100644 --- a/lib/youplot/command.rb +++ b/lib/youplot/command.rb @@ -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 diff --git a/lib/youplot/parser.rb b/lib/youplot/parser.rb index 633ff61..e13bded 100644 --- a/lib/youplot/parser.rb +++ b/lib/youplot/parser.rb @@ -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}'"