Module: Mayl::Commands

Defined in:
lib/mayl/commands.rb,
lib/mayl/commands/cd.rb,
lib/mayl/commands/ls.rb,
lib/mayl/commands/get.rb,
lib/mayl/commands/set.rb,
lib/mayl/commands/edit.rb,
lib/mayl/commands/exit.rb

Overview

Public: The Commands module is a namespace for all the commands that Mayl uses.

Defined Under Namespace

Classes: Cd, Edit, Exit, Get, Ls, Set

Class Method Summary collapse

Class Method Details

.autocomplete(line, env) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/mayl/commands.rb', line 5

def self.autocomplete(line, env)
  key = line.split.first || ''

  # Try to get namespaces or keys
  keys = env.autocomplete(key)
  return keys if keys.any?

  # If not, autocomplete commands
  opts = constants.map(&:to_s).map(&:downcase)
  opts.grep(/^#{Regexp.escape(key)}/)
end