Class: Githuh::CLI::Launcher
- Inherits:
-
Object
- Object
- Githuh::CLI::Launcher
- Defined in:
- lib/githuh/cli/launcher.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
Returns the value of attribute argv.
-
#command ⇒ Object
Returns the value of attribute command.
-
#kernel ⇒ Object
Returns the value of attribute kernel.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = nil) ⇒ Launcher
constructor
A new instance of Launcher.
Constructor Details
#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = nil) ⇒ Launcher
Returns a new instance of Launcher.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/githuh/cli/launcher.rb', line 13 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 |
Instance Attribute Details
#argv ⇒ Object
Returns the value of attribute argv.
11 12 13 |
# File 'lib/githuh/cli/launcher.rb', line 11 def argv @argv end |
#command ⇒ Object
Returns the value of attribute command.
11 12 13 |
# File 'lib/githuh/cli/launcher.rb', line 11 def command @command end |
#kernel ⇒ Object
Returns the value of attribute kernel.
11 12 13 |
# File 'lib/githuh/cli/launcher.rb', line 11 def kernel @kernel end |
#stderr ⇒ Object
Returns the value of attribute stderr.
11 12 13 |
# File 'lib/githuh/cli/launcher.rb', line 11 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
11 12 13 |
# File 'lib/githuh/cli/launcher.rb', line 11 def stdin @stdin end |
#stdout ⇒ Object
Returns the value of attribute stdout.
11 12 13 |
# File 'lib/githuh/cli/launcher.rb', line 11 def stdout @stdout end |
Instance Method Details
#execute! ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/githuh/cli/launcher.rb', line 27 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 self.command = ::Dry::CLI.new(::Githuh::CLI::Commands) command.call(arguments: argv, out: stdout, err: stderr) rescue StandardError => e box = TTY::Box.frame('ERROR:', ' ', e., **BOX_OPTIONS) stderr.print box ensure Githuh.restore_kernel_behavior! exit(10) unless Githuh.in_test end |