module Rack::App::CLI::DefaultCommands::ListCommands
Constants
- DEFAULT_COMMANDS
- PRESERVED_KEYWORDS
Public Instance Methods
get_message(known_commands)
click to toggle source
# File lib/rack/app/cli/default_commands/list_commands.rb, line 28 def get_message(known_commands) collection = {} add_default_suggestions(collection) add_user_defined_commands(known_commands, collection) [ header, Formatter.new(known_commands).format(collection) ].join("\n") end
Protected Instance Methods
add_default_suggestions(collection)
click to toggle source
# File lib/rack/app/cli/default_commands/list_commands.rb, line 49 def add_default_suggestions(collection) collection.merge!(DEFAULT_COMMANDS) end
add_user_defined_commands(known_commands, collection)
click to toggle source
# File lib/rack/app/cli/default_commands/list_commands.rb, line 53 def add_user_defined_commands(known_commands, collection) known_commands.sort_by { |name, _| name.to_s }.each do |name, command| collection[name] = command.class.description end end
header()
click to toggle source
# File lib/rack/app/cli/default_commands/list_commands.rb, line 41 def header cmd_file_name = File.basename($PROGRAM_NAME) [ "Usage: #{cmd_file_name} <command> [options] <args>\n\n", "Some useful #{cmd_file_name} commands are:" ].join("\n") end