lib/mayl/commands.rb in mayl-0.1.0 vs lib/mayl/commands.rb in mayl-0.2.0

- old
+ new

@@ -1,8 +1,19 @@ module Mayl # Public: The Commands module is a namespace for all the commands that Mayl # uses. module Commands + 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 end end require 'mayl/commands/set' require 'mayl/commands/get'