Module: Commands

Included in:
CommandFactory
Defined in:
lib/gdsh/commands.rb,
lib/gdsh/help.rb,
lib/gdsh/quit.rb,
lib/gdsh/clear.rb,
lib/gdsh/share.rb,
lib/gdsh/remove.rb,
lib/gdsh/get_file.rb,
lib/gdsh/list_files.rb,
lib/gdsh/unrecognized.rb,
lib/gdsh/command_mixin.rb,
lib/gdsh/revision_diff.rb,
lib/gdsh/query_revision.rb,
lib/gdsh/share_read_only.rb,
lib/gdsh/upload_template.rb,
lib/gdsh/share_read_write.rb

Overview

Commands

Defined Under Namespace

Modules: CommandMixin Classes: Clear, Command, GetFile, Help, ListFiles, QueryRevision, Quit, Remove, RevisionDiff, Share, ShareReadOnly, ShareReadWrite, Unrecognized, UploadTemplate

Class Method Summary collapse

Class Method Details

.commandsObject



26
27
28
# File 'lib/gdsh/commands.rb', line 26

def commands
  constants.select { |c| const_get(c).is_a? Class }
end

.interpret(input) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/gdsh/commands.rb', line 43

def interpret(input)
  return Quit if input.nil?

  commands.each do |c|
    klass = const_get(c)
    return klass if input == klass.command_name
  end

  Unrecognized
end

.puts_usage_headerObject



30
31
32
33
# File 'lib/gdsh/commands.rb', line 30

def puts_usage_header
  puts 'Commands'.colorize(:green)
  puts '--------'.colorize(:green)
end

.usageObject



35
36
37
38
39
40
41
# File 'lib/gdsh/commands.rb', line 35

def usage
  puts_usage_header
  commands.each do |c|
    klass = const_get(c)
    puts klass.description unless klass.command_name.empty?
  end
end