ubicloud/cli-commands/lb/post/show.rb
Jeremy Evans 3c5d544807 Show fields on their own lines
This fixes the worst cases in the help output in terms of long
lines.  There are still some option lines over 80 characters,
but at least all option lines are now under 100 characters (though
some usage lines are over 100 characters).
2025-02-21 09:32:10 -08:00

31 lines
865 B
Ruby

# frozen_string_literal: true
UbiCli.on("lb").run_on("show") do
fields = %w[id name state location hostname algorithm stack health-check-endpoint health-check-protocol src-port dst-port subnet vms].freeze.each(&:freeze)
options("ubi lb location/(lb-name|_lb-ubid) show [options]", key: :lb_show) do
on("-f", "--fields=fields", "show specific fields (comma separated)")
wrap("Fields:", fields)
end
run do |opts|
get(lb_path) do |data|
keys = underscore_keys(check_fields(opts[:lb_show][:fields], fields, "lb show -f option"))
body = []
keys.each do |key|
if key == "vms"
body << "vms:\n"
data[key].each do |vm_ubid|
body << " " << vm_ubid << "\n"
end
else
body << key << ": " << data[key].to_s << "\n"
end
end
body
end
end
end