Class: Rubee::CLI::Command

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

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.



4
5
6
7
# File 'lib/rubee/cli/command.rb', line 4

def initialize(argv)
  @command = argv[0]
  @argv = argv
end

Instance Method Details

#callObject



9
10
11
# File 'lib/rubee/cli/command.rb', line 9

def call
  factory.call(@command, @argv)
end

#factoryObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rubee/cli/command.rb', line 13

def factory
  case @command
  in /^(start|start_dev|stop|status)$/
    Rubee::CLI::Server
  in /^react$/
    Rubee::CLI::React
  in /^project$/
    Rubee::CLI::Project
  in /^version|v$/
    Rubee::CLI::Version
  in /^routes$/
    Rubee::CLI::Routes
  in /^test$/
    Rubee::CLI::Test
  in /^(generate|gen|g)$/
    Rubee::CLI::Generate
  in /^db$/
    Rubee::CLI::Db
  in /^(console|c)$/
    Rubee::CLI::Console
  in /^(attach|att)$/
    Rubee::CLI::Attach
  in /^bee$/
    Rubee::CLI::Bee
  else
    proc { color_puts("Unknown command: #{@command}", color: :red) }
  end
end