Class: Jackhammer::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CLI

Returns a new instance of CLI.



7
8
9
10
# File 'lib/jackhammer/cli.rb', line 7

def initialize(options = {})
  @logger = Logger.new $stderr
  @opts = { require: './config/environment' }.merge(options)
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
end

#optsObject (readonly)

Returns the value of attribute opts.



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

def opts
  @opts
end

Instance Method Details

#parse(argv = ARGV) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jackhammer/cli.rb', line 12

def parse(argv = ARGV)
  @parser = OptionParser.new do |o|
    o.on "-r", "--require PATH", "Location of application" do |arg|
      opts[:require] = arg
    end
  end
  @parser.banner = "jackhammer [options]"
  @parser.on_tail "-h", "--help", "Show help" do
    logger.info @parser
    exit
  end
  @parser.parse!(argv)
end

#runObject



26
27
28
29
30
# File 'lib/jackhammer/cli.rb', line 26

def run
  require opts[:require]
  Log.info "Booting up Jackhammer v#{VERSION}"
  server.start
end

#serverObject



32
33
34
# File 'lib/jackhammer/cli.rb', line 32

def server
  Jackhammer.configuration.server
end