class Bake::Command::List
List all available commands.
def call
def call first = true terminal = @parent.terminal context = @parent.context context.registry.each do |loader| printed = false loader.each do |path| loader.scopes_for(path) do |scope| print_scope(terminal, scope, printed: printed) do terminal.print_line(:loader, loader) printed = true end end end if printed terminal.print_line end end end
def format_parameters(parameters, terminal)
def format_parameters(parameters, terminal) parameters.each do |type, name| case type when :key name = "#{name}=" when :keyreq name = "#{name}=" when :keyrest name = "**#{name}" else name = name.to_s end terminal.print(:reset, " ") terminal.print(type, name) end end
def format_recipe(recipe, terminal)
def format_recipe(recipe, terminal) terminal.print(:command, recipe.command) if parameters = recipe.parameters format_parameters(parameters, terminal) end end
def print_scope(terminal, scope, printed: false)
def print_scope(terminal, scope, printed: false) format_recipe = self.method(:format_recipe).curry scope.recipes.sort.each do |recipe| if @pattern and !recipe.command.include?(pattern) next end unless printed yield printed = true end terminal.print_line terminal.print_line("\t", format_recipe[recipe]) documentation = recipe.documentation documentation.description do |line| terminal.print_line("\t\t", :description, line) end documentation.parameters do |parameter| terminal.print_line("\t\t", :parameter, parameter[:name], :reset, " [", :type, parameter[:type], :reset, "] ", :description, parameter[:details] ) end end return printed end