Class: Nirvana::Runner

Inherits:
Ripl::Runner
  • Object
show all
Defined in:
lib/nirvana/runner.rb

Constant Summary collapse

EXIT_OPTIONS =
%w{-h --help -v --version}

Class Method Summary collapse

Class Method Details

.run_command(argv) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/nirvana/runner.rb', line 6

def self.run_command(argv)
  begin
    cmd = argv.shift
    require "ripl/#{cmd}"
  rescue LoadError
    abort "`#{cmd}' is not a nirvana command."
  end
  start
end

.start(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nirvana/runner.rb', line 16

def self.start(options={})
  @argv = options[:argv]
  parse_options @argv.dup
  stdout, stderr = Util.capture_all {
    load_rc(Ripl.config[:riplrc]) unless @argv.include? '-F'
    Ripl::Shell.include Nirvana::Shell
    (Ripl.config[:hirb] ||= {})[:pager] = false if defined? Hirb
    Ripl.shell(:name=>'nirvana', :readline=>false).before_loop
  }
  (result = stdout.to_s + stderr.to_s) ? Util.format_output(result) : result
end