Module: Dry::CLI::Banner
- Defined in:
- lib/patches/dry-cli.rb
Class Method Summary collapse
-
.call(command, name) ⇒ String
Overwrites the original ‘call’ method to accommodate a custom header and footer for the help text.
-
.command_help_wrapper(command) ⇒ Array<String>
Provides the header and footer for the received command.
- .original_call ⇒ Object
Class Method Details
.call(command, name) ⇒ String
Overwrites the original ‘call’ method to accommodate a custom header and footer for the help text.
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/patches/dry-cli.rb', line 79 def call(command, name) help_text = original_call(command, name) my_header, = command_help_wrapper(command) help_text.prepend(my_header) help_text += help_text end |
.command_help_wrapper(command) ⇒ Array<String>
Provides the header and footer for the received command.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/patches/dry-cli.rb', line 96 def command_help_wrapper(command) global_header = Dry::CLI::Command.global_header = Dry::CLI::Command. command_header = command.header = command. my_header = "" my_header += global_header + "\n" unless (global_header.nil? || global_header.empty?) my_header += command_header+ "\n" unless (command_header.nil?|| command_header.empty?) = "" += "\n" + unless (.nil?|| .empty?) += "\n" + unless (.nil? || .empty?) [my_header, ] end |
.original_call ⇒ Object
71 |
# File 'lib/patches/dry-cli.rb', line 71 alias_method :original_call, :call |