mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-07 23:51:12 +08:00
Improved main help menu
This commit is contained in:
parent
a6ff1ebf2e
commit
159b90998b
@ -31,7 +31,7 @@ module Uplot
|
|||||||
opt.summary_width = 24
|
opt.summary_width = 24
|
||||||
opt.on_tail('') # Add a blank line at the end
|
opt.on_tail('') # Add a blank line at the end
|
||||||
opt.separator('')
|
opt.separator('')
|
||||||
opt.on('Options:')
|
opt.on('Common options:')
|
||||||
opt.on('-O', '--pass [VAL]', 'file to output standard input data to [stdout]',
|
opt.on('-O', '--pass [VAL]', 'file to output standard input data to [stdout]',
|
||||||
'for inserting uplot in the middle of Unix pipes') do |v|
|
'for inserting uplot in the middle of Unix pipes') do |v|
|
||||||
@pass = v || $stdout
|
@pass = v || $stdout
|
||||||
@ -97,6 +97,9 @@ module Uplot
|
|||||||
def main_parser
|
def main_parser
|
||||||
@main_parser ||= create_default_parser do |main_parser|
|
@main_parser ||= create_default_parser do |main_parser|
|
||||||
# Usage and help messages
|
# Usage and help messages
|
||||||
|
# Here, help is stored in the banner.
|
||||||
|
# Because help of main_parser may be called by sub_parser method,
|
||||||
|
# local variable is not used.
|
||||||
main_parser.banner = \
|
main_parser.banner = \
|
||||||
<<~MSG
|
<<~MSG
|
||||||
|
|
||||||
@ -118,7 +121,20 @@ module Uplot
|
|||||||
|
|
||||||
count c draw a baplot based on the number of
|
count c draw a baplot based on the number of
|
||||||
occurrences (slow)
|
occurrences (slow)
|
||||||
|
|
||||||
|
General options:
|
||||||
|
--help print command specific help menu
|
||||||
|
--version print the version of uplot
|
||||||
MSG
|
MSG
|
||||||
|
|
||||||
|
# Actually, main_parser can take common optional arguments.
|
||||||
|
# However, these options dose not be shown in the help menu.
|
||||||
|
# I think the main help should be simple.
|
||||||
|
main_parser.on('--help', 'print sub-command help menu') do
|
||||||
|
puts main_parser.banner
|
||||||
|
puts
|
||||||
|
exit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -132,8 +148,11 @@ module Uplot
|
|||||||
MSG
|
MSG
|
||||||
|
|
||||||
case command
|
case command
|
||||||
|
|
||||||
|
# If you type only `uplot` in the terminal.
|
||||||
when nil
|
when nil
|
||||||
warn main_parser.help
|
warn main_parser.banner
|
||||||
|
warn "\n"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
when :barplot, :bar
|
when :barplot, :bar
|
||||||
|
Loading…
Reference in New Issue
Block a user