mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-05 22:31:11 +08:00
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:
parent
f9ffca636f
commit
f8bd152a63
@ -192,12 +192,16 @@ module YouPlot
|
|||||||
# Help for the main parser is simple.
|
# Help for the main parser is simple.
|
||||||
# Simply show the banner above.
|
# Simply show the banner above.
|
||||||
main_parser.on('--help', 'print sub-command help menu') do
|
main_parser.on('--help', 'print sub-command help menu') do
|
||||||
puts main_parser.banner
|
show_main_help
|
||||||
puts
|
|
||||||
exit if YouPlot.run_as_executable?
|
|
||||||
end
|
end
|
||||||
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
|
def sub_parser_add_symbol
|
||||||
sub_parser.on_head('--symbol STR', String, 'character to be used to plot the bars') do |v|
|
sub_parser.on_head('--symbol STR', String, 'character to be used to plot the bars') do |v|
|
||||||
params.symbol = v
|
params.symbol = v
|
||||||
@ -265,10 +269,13 @@ module YouPlot
|
|||||||
case command
|
case command
|
||||||
|
|
||||||
# If you type only `uplot` in the terminal.
|
# If you type only `uplot` in the terminal.
|
||||||
|
# Output help to standard error output.
|
||||||
when nil
|
when nil
|
||||||
warn main_parser.banner
|
show_main_help($stderr)
|
||||||
warn "\n"
|
|
||||||
exit 1 if YouPlot.run_as_executable?
|
# Output help to standard output.
|
||||||
|
when :help
|
||||||
|
show_main_help
|
||||||
|
|
||||||
when :barplot, :bar
|
when :barplot, :bar
|
||||||
sub_parser_add_symbol
|
sub_parser_add_symbol
|
||||||
|
Loading…
Reference in New Issue
Block a user