Class: Jackhammer::CLI
- Inherits:
-
Object
- Object
- Jackhammer::CLI
- Defined in:
- lib/jackhammer/cli.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CLI
constructor
A new instance of CLI.
- #parse(argv = ARGV) ⇒ Object
- #run ⇒ Object
- #server ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 |
# File 'lib/jackhammer/cli.rb', line 7 def initialize( = {}) @logger = Logger.new $stderr @opts = { require: './config/environment' }.merge() end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/jackhammer/cli.rb', line 5 def logger @logger end |
#opts ⇒ Object (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. = "jackhammer [options]" @parser.on_tail "-h", "--help", "Show help" do logger.info @parser exit end @parser.parse!(argv) end |
#run ⇒ Object
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 |
#server ⇒ Object
32 33 34 |
# File 'lib/jackhammer/cli.rb', line 32 def server Jackhammer.configuration.server end |