class Runfile::Entrypoint
Serves as the initial entrypoint when running run
.
Attributes
argv[R]
Public Class Methods
new(argv = ARGV)
click to toggle source
# File lib/runfile/entrypoint.rb, line 10 def initialize(argv = ARGV) @argv = argv end
Public Instance Methods
handler()
click to toggle source
# File lib/runfile/entrypoint.rb, line 14 def handler rootfile || Initiator.new end
inspectable()
click to toggle source
# File lib/runfile/entrypoint.rb, line 18 def inspectable { argv: argv } end
run()
click to toggle source
# File lib/runfile/entrypoint.rb, line 22 def run handler.run argv end
run!()
click to toggle source
# 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
Private Instance Methods
allow_debug(e)
click to toggle source
# File lib/runfile/entrypoint.rb, line 49 def allow_debug(e) return unless ENV['DEBUG'] say! e.backtrace.reverse.join("\n") say! '---' end
origin(e)
click to toggle source
# File lib/runfile/entrypoint.rb, line 56 def origin(e) (e.backtrace_locations&.first.to_s || e.backtrace&.first || 'unknown') .tr '`', "'" end
rootfile()
click to toggle source
# File lib/runfile/entrypoint.rb, line 61 def rootfile if File.file? 'runfile' Userfile.new 'runfile' elsif File.file? 'Runfile' Userfile.new 'Runfile' end end