Adds support for nested args in cli's help (#8074)

See https://github.com/redis/redis-doc/pull/1443

Also allows nameless commands.
This commit is contained in:
Itamar Haber 2020-11-30 15:00:16 +02:00 committed by GitHub
parent ada2ac9ae2
commit d322e7baba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,9 +25,15 @@ GROUPS_BY_NAME = Hash[*
].freeze
def argument arg
name = arg["name"].is_a?(Array) ? arg["name"].join(" ") : arg["name"]
name = arg["enum"].join "|" if "enum" == arg["type"]
name = arg["command"] + " " + name if arg["command"]
if "block" == arg["type"]
name = arg["block"].map do |entry|
argument entry
end.join " "
else
name = arg["name"].is_a?(Array) ? arg["name"].join(" ") : arg["name"]
name = arg["enum"].join "|" if "enum" == arg["type"]
name = arg["command"] + (name ? " " + name : "") if arg["command"]
end
if arg["multiple"]
name = "#{name} [#{name} ...]"
end