Sha256: c2c1297ffbbd552bf8780a000ed809d5ec5ce5e1a0b2dfdb32ac60515da67e8b

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

module SpicedRumby
  class CLIInput < MeshChat::CLI::Base
    class << self
      def autocompletes
        commands = MeshChat::CLI::COMMAND_MAP.map{ |k, v| "/#{k}" }
        aliases = MeshChat::Node.all.map{ |n| "#{n.alias_name}" }
        commands + aliases
      end
    end

    # called every time meshchat wants a line of text from the user
    def get_input
      # update auto completion
      completion = proc{ |s| self.class.autocompletes.grep(/^#{Regexp.escape(s)}/) }
      Readline.completion_proc = completion

      Readline.readline('> ', true)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spiced_rumby-0.7.0 lib/spiced_rumby/cli_input.rb
spiced_rumby-0.6.0 lib/spiced_rumby/cli_input.rb