Improved the way help is displayed

- Add `help` to the subcommand.
- Use same method to display help in stdout or stderr.
This commit is contained in:
kojix2 2023-01-05 11:57:46 +09:00
parent f9ffca636f
commit f8bd152a63

View File

@ -192,12 +192,16 @@ module YouPlot
# Help for the main parser is simple.
# Simply show the banner above.
main_parser.on('--help', 'print sub-command help menu') do
puts main_parser.banner
puts
exit if YouPlot.run_as_executable?
show_main_help
end
end
def show_main_help(out = $stdout)
out.puts main_parser.banner
out.puts
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
@ -265,10 +269,13 @@ module YouPlot
case command
# If you type only `uplot` in the terminal.
# Output help to standard error output.
when nil
warn main_parser.banner
warn "\n"
exit 1 if YouPlot.run_as_executable?
show_main_help($stderr)
# Output help to standard output.
when :help
show_main_help
when :barplot, :bar
sub_parser_add_symbol