Class: Runfile::Entrypoint

Inherits:
Object
  • Object
show all
Includes:
Colsole, Inspectable, Renderable
Defined in:
lib/runfile/entrypoint.rb

Overview

Serves as the initial entrypoint when running run.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Renderable

#render

Methods included from Inspectable

#inspect

Constructor Details

#initialize(argv = ARGV) ⇒ Entrypoint

Returns a new instance of Entrypoint.



10
11
12
# File 'lib/runfile/entrypoint.rb', line 10

def initialize(argv = ARGV)
  @argv = argv
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



8
9
10
# File 'lib/runfile/entrypoint.rb', line 8

def argv
  @argv
end

Instance Method Details

#handlerObject



14
15
16
# File 'lib/runfile/entrypoint.rb', line 14

def handler
  rootfile || Initiator.new
end

#inspectableObject



18
19
20
# File 'lib/runfile/entrypoint.rb', line 18

def inspectable
  { argv: argv }
end

#runObject



22
23
24
# File 'lib/runfile/entrypoint.rb', line 22

def run
  handler.run argv
end

#run!Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/runfile/entrypoint.rb', line 26

def run!
  run
rescue Runfile::ExitWithUsage => e
  say e.message
  e.exit_code
rescue Runfile::UserError => e
  allow_debug e
  say! "mib` #{e.class} `"
  say! e.message
  1
rescue Interrupt
  say! 'm`Goodbye`', replace: true
  1
rescue => e
  allow_debug e
  say! "rib` #{e.class} ` in nu`#{origin(e)}`"
  say! e.message
  say! "\nPrefix with nu`DEBUG=1` for full backtrace" unless ENV['DEBUG']
  1
end