Class: TQ::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/tq/shell.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  app: {},
  auth_secrets_file: './tq-client.json',
  auth_store_file:   './tq-client-store.json',
  config_file:       './tq-app.json'
}

Instance Method Summary collapse

Constructor Details

#initialize(app, logger = nil) ⇒ Shell

Returns a new instance of Shell.



16
17
18
19
20
# File 'lib/tq/shell.rb', line 16

def initialize(app, logger=nil)
  @app = app
  @logger = logger
  @summary = []
end

Instance Method Details



22
23
24
# File 'lib/tq/shell.rb', line 22

def banner(_)
  @banner = _; return self
end

#call(argv = ARGV) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/tq/shell.rb', line 30

def call(argv=ARGV)
  
  progname = File.basename(__FILE__,'.rb')

  @logger.info(progname) { "Configuring #{@app.id}" } if @logger
  opts = parse_args(argv)
  @logger.debug(progname) { "Configuration: #{opts[:app].inspect}" } if @logger

  @app = @app.options( opts[:app] ).logger(@logger)

  @logger.info(progname) { "Running #{@app.id} using worker #{@app.worker}" } if @logger
  @app.run!( opts[:auth_secrets_file], opts[:auth_store_file] )

end

#summary(*_) ⇒ Object



26
27
28
# File 'lib/tq/shell.rb', line 26

def summary(*_)
  @summary = _; return self
end