Class: Lucid::CLI::App
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args, stdin = STDIN, out = STDOUT, err = STDERR, kernel = Kernel) ⇒ App
constructor
A new instance of App.
- #load_context ⇒ Object
- #start!(existing_context = nil) ⇒ Object
Constructor Details
#initialize(args, stdin = STDIN, out = STDOUT, err = STDERR, kernel = Kernel) ⇒ App
Returns a new instance of App.
15 16 17 18 19 20 21 |
# File 'lib/lucid/cli/app.rb', line 15 def initialize(args, stdin=STDIN, out=STDOUT, err=STDERR, kernel=Kernel) @args = args @out = out @err = err @kernel = kernel @context = nil end |
Class Method Details
.start(args) ⇒ Object
11 12 13 |
# File 'lib/lucid/cli/app.rb', line 11 def self.start(args) new(args).start! end |
Instance Method Details
#load_context ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/lucid/cli/app.rb', line 53 def load_context return @context if @context @context = Context.new(@out, @err) @context.(@args) Lucid.logger = @context.log log.debug('Context:') log.debug(@context) @context end |
#start!(existing_context = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lucid/cli/app.rb', line 23 def start!(existing_context=nil) trap_interrupt context_loader = if existing_context existing_context.configure(load_context) existing_context else ContextLoader.new(load_context) end log.debug('Context Loader') log.debug(context_loader) context_loader.execute context_loader.write_testdefs_json failure = context_loader.results.failure? || Lucid.wants_to_quit @kernel.exit(failure ? 1 : 0) rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e @err.puts(e.) rescue SystemExit => e @kernel.exit(e.status) rescue Errno::EACCES, Errno::ENOENT => e @err.puts("#{e.} (#{e.class})") @kernel.exit(1) rescue Exception => e @err.puts("#{e.} (#{e.class})") @err.puts(e.backtrace.join("\n")) @kernel.exit(1) end |