Class: Evergreen::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/evergreen/cli.rb

Overview

Translates the arguments passed in from the command line

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.execute(argv) ⇒ Object


4
5
6
# File 'lib/evergreen/cli.rb', line 4

def self.execute(argv)
  new.execute(argv)
end

Instance Method Details

#execute(argv) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/evergreen/cli.rb', line 8

def execute(argv)
  command = argv.shift
  Evergreen.root = File.expand_path(argv.shift || '.', Dir.pwd)

  # detect Rails apps
  if File.exist?(File.join(Evergreen.root, 'config/environment.rb'))
    require File.join(Evergreen.root, 'config/environment.rb')
    require 'evergreen/rails' if defined?(Rails)
  end

  case command
  when "serve"
    Evergreen::Server.new.serve
    return true
  when "run"
    return Evergreen::Runner.new.run
  else
    puts "no such command '#{command}'"
    return false
  end
end