Class: Fastball::CLI

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

Constant Summary collapse

HELP =
"  usage: fastball COMMAND [options]\n\n  Fastball is the safest, fastest way to build and deploy dynamic applications.\n\n  Commands:\n    config - generate config files from erb templates\n\n  Examples:\n    fastball config\n"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI



19
20
21
22
# File 'lib/fastball/cli.rb', line 19

def initialize(argv)
  @argv = argv
  @command = argv.shift
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



5
6
7
# File 'lib/fastball/cli.rb', line 5

def argv
  @argv
end

Class Method Details

.help_textObject



24
25
26
# File 'lib/fastball/cli.rb', line 24

def self.help_text
  HELP.gsub(/^ {6}/, '')
end

Instance Method Details

#help_textObject



28
29
30
# File 'lib/fastball/cli.rb', line 28

def help_text
  self.class.help_text
end

#runObject



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

def run
  case @command
  when 'config'
    Fastball::Config.generate
  when 'help'
    puts help_text
  else
    puts help_text
    exit 1
  end
end