Class: Totem::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/totem/shell.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Shell

Returns a new instance of Shell.



11
12
13
# File 'lib/totem/shell.rb', line 11

def initialize(args)
  @args = args
end

Class Method Details

.register_cmd(cmd, klass) ⇒ Object



5
6
7
8
9
# File 'lib/totem/shell.rb', line 5

def self.register_cmd(cmd, klass)
  @cmds[cmd.to_sym] = klass

  return nil
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/totem/shell.rb', line 15

def run
  env_path = 'config/environment.rb'
  if File.exists?(env_path)
    load(env_path)
  else
    puts "Unable to find #{env_path}.  You must run this command from your project root directory."
    exit
  end

  if @args[0].nil?
    puts_usage
    return
  end

  cmd_to_class(@args[0]).new(@args[1..-1]).run
end