Module: Harp

Defined in:
lib/harp/repl.rb,
lib/harp.rb,
lib/harp/cli.rb,
lib/harp/command_manager.rb

Overview

Readline.basic_word_break_characters = “”

Defined Under Namespace

Classes: CLI, Command, CommandManager, REPL

Class Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/harp.rb', line 6

def self.included(mod)
  mod.module_eval do
    @command_manager = CommandManager.new

    def self.setup_harp(&block)
      command_manager = @command_manager
      # This should either be baked in to REPL, or non-existent.
      @command_manager.command("quit") do
        exit
      end
      @command_manager.instance_exec(command_manager, &block)
    end

    def self.repl
      REPL.new(@command_manager)
    end

    def repl
      self.class.repl.run(self)
    end

    def self.cli
      CLI.new(@command_manager)
    end

    def cli
      self.class.cli.run(self)
    end
  end
end