class Githuh::CLI::Launcher
Attributes
argv[RW]
command[RW]
kernel[RW]
stderr[RW]
stdin[RW]
stdout[RW]
Public Class Methods
new(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = nil)
click to toggle source
# File lib/githuh/cli/launcher.rb, line 16 def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = nil) if ::Githuh.launcher raise(ArgumentError, "Another instance of CLI Launcher was detected, aborting.") else Githuh.launcher = self end self.argv = argv self.stdin = stdin self.stdout = stdout self.stderr = stderr self.kernel = kernel end
Public Instance Methods
execute!()
click to toggle source
# File lib/githuh/cli/launcher.rb, line 30 def execute! if argv.empty? || !(%w(--help -h) & argv).empty? stdout.puts BANNER Githuh.configure_kernel_behavior! help: true else Githuh.configure_kernel_behavior! end # noinspection RubyYardParamTypeMatch self.command = ::Dry::CLI.new(::Githuh::CLI::Commands) command.call(arguments: argv, out: stdout, err: stderr) rescue StandardError => e lines = [e.message.gsub(/\n/, ', ')] if e.backtrace && !(ARGV & %w[-v --verbose]).empty? lines << '' lines.concat(e.backtrace) end box = TTY::Box.frame(*lines, **BOX_OPTIONS.merge( width: TTY::Screen.width, title: { top_center: "┤ #{e.class.name} ├" }, )) stderr.puts stderr.print box ensure Githuh.restore_kernel_behavior! exit(0) unless Githuh.in_test end
trace?()
click to toggle source
# File lib/githuh/cli/launcher.rb, line 60 def trace? argv.include?('-t') || argv.include?('--trace') end