Show available option values in separate section after options display. In cases where Options can be taken from elsewhere in the application, do that instead of hard coding the options. This allows burstable-1 and burstable-2 to show up as VM/PG size options, and show more available VM/PG storage sizes. This doesn't show which storage sizes are valid for a given VM/PG size. That's possible but would clutter the display. Update to a later rodish checkout, which moved some of the features UbiCli uses to plugins, and load those plugins.
53 lines
1.3 KiB
Ruby
53 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
UbiCli.on("help") do
|
|
desc "Get command help"
|
|
|
|
options("ubi help [options] [command [subcommand]]") do
|
|
on("-r", "--recursive", "also show documentation for all subcommands of command")
|
|
on("-u", "--usage", "only show usage")
|
|
end
|
|
|
|
args(0..)
|
|
|
|
run do |argv, opts|
|
|
orig_command = command = UbiCli.command
|
|
|
|
argv.each do |arg|
|
|
break unless (command = command.subcommand(arg) || command.post_subcommand(arg))
|
|
orig_command = command
|
|
end
|
|
|
|
usage = opts[:usage]
|
|
if command
|
|
if opts[:recursive]
|
|
body = []
|
|
command.each_subcommand do |_, cmd|
|
|
if usage
|
|
cmd.each_banner do |banner|
|
|
body << banner << "\n"
|
|
end
|
|
else
|
|
# When we want to switch to context-sensitive help
|
|
# body << cmd.context_help(self) << "\n\n"
|
|
body << cmd.help << "\n\n"
|
|
end
|
|
end
|
|
response(body)
|
|
elsif usage
|
|
body = []
|
|
command.each_banner do |banner|
|
|
body << banner << "\n"
|
|
end
|
|
response(body)
|
|
else
|
|
# When we want to switch to context-sensitive help
|
|
# response(command.context_help(self))
|
|
response(command.help)
|
|
end
|
|
else
|
|
orig_command.raise_failure("invalid command: #{argv.join(" ")}")
|
|
end
|
|
end
|
|
end
|