Module: Expedite::Cli

Defined in:
lib/expedite/cli.rb,
lib/expedite/cli/stop.rb,
lib/expedite/cli/rails.rb,
lib/expedite/cli/server.rb,
lib/expedite/cli/status.rb

Defined Under Namespace

Classes: Help, Rails, Server, Status, Stop, UnknownCommandError

Class Method Summary collapse

Class Method Details

.command(cmd) ⇒ Object



51
52
53
54
55
# File 'lib/expedite/cli.rb', line 51

def command(cmd)
  klass = commands[cmd]
  raise UnknownCommandError, "Unknown command '#{cmd}'" if klass.nil?
  klass.new
end

.commandsObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/expedite/cli.rb', line 31

def commands
  return @commands unless @commands.nil?

  cmds = {
    'help'   => Cli::Help,
    'server' => Cli::Server,
    'status' => Cli::Status,
    'stop'   => Cli::Stop,
  }
  cmds['rails'] = Cli::Rails if Gem.loaded_specs["rails"]
  @commands = cmds
end

.run(args) ⇒ Object



44
45
46
47
48
49
# File 'lib/expedite/cli.rb', line 44

def run(args)
  command(args.first).run(args[1..])
rescue UnknownCommandError => e
  STDERR.puts e
  Cli::Help.new.run([])
end