Module: DnsMadeEasy::CLI::MessageHelpers
- Included in:
- Commands::Base
- Defined in:
- lib/dnsmadeeasy/cli/message_helpers.rb
Overview
Colorful boxed CLI status messages. All boxes print to stderr so that stdout carries only command payload (zone files, plan output) and stays safe to pipe or redirect.
Include the module to call info/success/warning/error directly from a command; boxes then print to the includer's @err stream when present. The module-level methods (MessageHelpers.error etc.) remain available for callers outside the command classes.
Defined Under Namespace
Modules: InstanceMethods
Constant Summary collapse
- BOX_OPTIONS =
{ border: { type: :thick }, width: 85 }.freeze
Class Attribute Summary collapse
-
.stderr ⇒ Object
Returns the value of attribute stderr.
-
.stdout ⇒ Object
Returns the value of attribute stdout.
Class Method Summary collapse
- .error(message) ⇒ Object
- .included(base) ⇒ Object
- .info(message) ⇒ Object
- .print_box(box_type, message, output) ⇒ Object
- .success(message) ⇒ Object
- .warn(message) ⇒ Object
Class Attribute Details
.stderr ⇒ Object
Returns the value of attribute stderr.
22 23 24 |
# File 'lib/dnsmadeeasy/cli/message_helpers.rb', line 22 def stderr @stderr end |
.stdout ⇒ Object
Returns the value of attribute stdout.
22 23 24 |
# File 'lib/dnsmadeeasy/cli/message_helpers.rb', line 22 def stdout @stdout end |
Class Method Details
.error(message) ⇒ Object
36 37 38 |
# File 'lib/dnsmadeeasy/cli/message_helpers.rb', line 36 def error() print_box(:error, , stderr) end |
.included(base) ⇒ Object
24 25 26 |
# File 'lib/dnsmadeeasy/cli/message_helpers.rb', line 24 def included(base) base.include(InstanceMethods) end |
.info(message) ⇒ Object
28 29 30 |
# File 'lib/dnsmadeeasy/cli/message_helpers.rb', line 28 def info() print_box(:info, , stderr) end |
.print_box(box_type, message, output) ⇒ Object
44 45 46 47 48 |
# File 'lib/dnsmadeeasy/cli/message_helpers.rb', line 44 def print_box(box_type, , output) box = TTY::Box.public_send(box_type, , **BOX_OPTIONS) output.puts(box) box end |
.success(message) ⇒ Object
40 41 42 |
# File 'lib/dnsmadeeasy/cli/message_helpers.rb', line 40 def success() print_box(:success, , stderr) end |
.warn(message) ⇒ Object
32 33 34 |
# File 'lib/dnsmadeeasy/cli/message_helpers.rb', line 32 def warn() print_box(:warn, , stderr) end |