Class: ListCommand

Inherits:
Command show all
Defined in:
lib/replicant/commands/list_command.rb

Constant Summary

Constants included from Styles

Styles::CONSOLE_WIDTH, Styles::REPL_OUT, Styles::STYLES

Instance Attribute Summary

Attributes inherited from Command

#args

Instance Method Summary collapse

Methods inherited from Command

all, #execute, inherited, #initialize, load, #name, #usage

Methods included from Styles

#create_style, #end_style, #styled_text

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#descriptionObject



6
7
8
# File 'lib/replicant/commands/list_command.rb', line 6

def description
  "print a list of available commands"
end

#runObject



10
11
12
13
14
15
16
17
# File 'lib/replicant/commands/list_command.rb', line 10

def run
  command_list = Command.all.sort_by {|c| c.name}.map do |command|
    padding = 20 - command.name.length
    desc = "#{command.name} #{' ' * padding} -- #{command.description}"
    desc
  end
  output command_list.join("\n")
end

#valid_args?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/replicant/commands/list_command.rb', line 2

def valid_args?
  args.blank?
end