Class: TQ::Shell
- Inherits:
-
Object
- Object
- TQ::Shell
- Defined in:
- lib/tq/shell.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ app: {}, config_file: './tq-app.json' }
Instance Method Summary collapse
- #banner(_) ⇒ Object
- #call(argv = ARGV) ⇒ Object
-
#initialize(app, logger = nil) ⇒ Shell
constructor
A new instance of Shell.
- #summary(*_) ⇒ Object
Constructor Details
#initialize(app, logger = nil) ⇒ Shell
Returns a new instance of Shell.
14 15 16 17 18 |
# File 'lib/tq/shell.rb', line 14 def initialize(app, logger=nil) @app = app @logger = logger @summary = [] end |
Instance Method Details
#banner(_) ⇒ Object
20 21 22 |
# File 'lib/tq/shell.rb', line 20 def (_) @banner = _; return self end |
#call(argv = ARGV) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tq/shell.rb', line 28 def call(argv=ARGV) progname = File.basename(__FILE__,'.rb') opts = parse_args(argv) @logger.debug(progname) { "Configuration for #{@app.id}: #{opts.inspect}" } if @logger @app = @app.( opts[:app] ) @app = @app.logger(@logger) if @logger @logger.info(progname) { "Running #{@app.id} using worker #{@app.worker}" } if @logger secrets, store = opts[:auth_secrets_file], opts[:auth_store_file] issuer, p12 = opts[:service_auth_issuer_file], opts[:service_auth_p12_file] if secrets @app.run!(secrets, store) elsif issuer && p12 @app.service_run!(File.read(issuer).chomp, p12) else raise ArgumentError, "You must provide either OAuth2 secrets and credentials store, " + "or service-account issuer and p12 files." end @logger.info(progname) { "Completed #{@app.id}" } if @logger end |
#summary(*_) ⇒ Object
24 25 26 |
# File 'lib/tq/shell.rb', line 24 def summary(*_) @summary = _; return self end |