Method: Conify::Command#usage_info
- Defined in:
- lib/conify/command.rb
#usage_info(map) ⇒ Object
Format a map of commands into help output format
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/conify/command.rb', line 218 def usage_info(map) keys = map.keys commands_column_width = keys.max_by(&:length).length + 1 commands_column_width += 2 if commands_column_width < 12 # iterate through each of the commands, create an array # of strings in a `<command> # <description>` format. Sort # them alphabetically, and then join them with new lines. keys.map { |key| command = " #{key}" command += (' ' * (commands_column_width - key.length + 1)) command += "# #{map[key][:description]}" command }.sort_by{ |k| k.downcase }.join("\n") end |