Module: Githuh

Extended by:
Forwardable
Defined in:
lib/githuh.rb,
lib/githuh.rb,
lib/githuh/version.rb,
lib/githuh/cli/launcher.rb,
lib/githuh/cli/commands/base.rb,
lib/githuh/cli/commands/version.rb,
lib/githuh/cli/commands/repo/list.rb,
lib/githuh/cli/commands/user/info.rb,
lib/githuh/cli/commands/issue/export.rb,
lib/githuh/cli/commands/issue/export_paginated.rb

Defined Under Namespace

Modules: CLI

Constant Summary collapse

"Githuh Version #{VERSION}"
BINARY =
File.expand_path('../exe/githuh', __dir__).freeze
VERSION =
'0.3.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.in_testObject

Returns the value of attribute in_test.



28
29
30
# File 'lib/githuh.rb', line 28

def in_test
  @in_test
end

.launcherObject

Returns the value of attribute launcher.



28
29
30
# File 'lib/githuh.rb', line 28

def launcher
  @launcher
end

Class Method Details

.configure_kernel_behavior!(help: false) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/githuh.rb', line 34

def configure_kernel_behavior!(help: false)
  Kernel.module_eval do
    alias original_exit exit
    alias original_puts puts
    alias original_warn warn
  end

  Kernel.module_eval do
    def puts(*args)
      ::Githuh.stdout.puts(*args)
    end

    def warn(*args)
      ::Githuh.stderr.puts(*args)
    end
  end

  if in_test
    Kernel.module_eval do
      def exit(code)
        ::Githuh.stderr.puts("RSpec: intercepted exit code: #{code}")
      end
    end
  elsif help
    Kernel.module_eval do
      def exit(_code)
        # for help, override default exit code with 0
        original_exit(0)
      end
    end
  else
    Kernel.module_eval do
      def exit(code)
        original_exit(code)
      end
    end
  end

  Dry::CLI
end

.restore_kernel_behavior!Object



75
76
77
78
79
80
81
82
# File 'lib/githuh.rb', line 75

def restore_kernel_behavior!
  Kernel.module_eval do
    alias exit original_exit
    alias puts original_puts
    alias warn original_warn
    alias exit original_exit
  end
end