class R2do::Commands::DisplayCategoriesCommand
Public Class Methods
new(state)
click to toggle source
Calls superclass method
R2do::Command::new
# File lib/r2do/commands/display_categories.rb, line 21 def initialize(state) super('l', 'list', 'Displays all the categories.') @state = state end
Public Instance Methods
execute(args)
click to toggle source
Displays all the categories available
@param [Array] args the arguments passed to the app by the user @return [void]
# File lib/r2do/commands/display_categories.rb, line 31 def execute(args) if @state.categories.empty? UI.status("No categories to display") else @state.categories.each do |key, value| current = (value == @state.current_category && "*") || ' ' UI.status("#{current} #{value.name}") end end end
help()
click to toggle source
# File lib/r2do/commands/display_categories.rb, line 42 def help() help = <<-EOF NAME r2do #{@extended} SYNOPSIS 'r2do #{@extended}' or 'r2do #{@short}' are equivalent DESCRIPTION The #{@extended} lets you Lists all the available categories in the application. The current selected category is marked with and asterisk '*' usage: r2do #{@extended} e.g. Category 1 * Category 2 Category 3 EOF end