Class: Sxn::UI::Output
- Inherits:
-
Object
- Object
- Sxn::UI::Output
- Defined in:
- lib/sxn/ui/output.rb
Overview
Formatted output with colors and status indicators
Instance Method Summary collapse
- #command_example(command, description = nil) ⇒ Object
- #debug(message) ⇒ Object
- #empty_state(message) ⇒ Object
- #error(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize ⇒ Output
constructor
A new instance of Output.
- #key_value(key, value, indent: 0) ⇒ Object
- #list_item(item, description = nil) ⇒ Object
- #newline ⇒ Object
- #progress_done ⇒ Object
- #progress_failed ⇒ Object
- #progress_start(message) ⇒ Object
- #recovery_suggestion(message) ⇒ Object
- #section(title) ⇒ Object
- #status(label, message, color = :blue) ⇒ Object
- #subsection(title) ⇒ Object
- #success(message) ⇒ Object
- #warning(message) ⇒ Object
Constructor Details
#initialize ⇒ Output
Returns a new instance of Output.
9 10 11 |
# File 'lib/sxn/ui/output.rb', line 9 def initialize @pastel = Pastel.new end |
Instance Method Details
#command_example(command, description = nil) ⇒ Object
90 91 92 93 94 |
# File 'lib/sxn/ui/output.rb', line 90 def command_example(command, description = nil) puts " #{@pastel.dim(description)}" if description puts " #{@pastel.cyan("$ #{command}")}" puts "" end |
#debug(message) ⇒ Object
29 30 31 |
# File 'lib/sxn/ui/output.rb', line 29 def debug() puts @pastel.dim("đ #{}") if debug_mode? end |
#empty_state(message) ⇒ Object
60 61 62 |
# File 'lib/sxn/ui/output.rb', line 60 def empty_state() puts @pastel.dim(" #{}") end |
#error(message) ⇒ Object
17 18 19 |
# File 'lib/sxn/ui/output.rb', line 17 def error() puts @pastel.red("â #{}") end |
#info(message) ⇒ Object
25 26 27 |
# File 'lib/sxn/ui/output.rb', line 25 def info() puts @pastel.blue("âšī¸ #{}") end |
#key_value(key, value, indent: 0) ⇒ Object
64 65 66 67 |
# File 'lib/sxn/ui/output.rb', line 64 def key_value(key, value, indent: 0) spacing = " " * indent puts "#{spacing}#{@pastel.bold(key)}: #{value}" end |
#list_item(item, description = nil) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/sxn/ui/output.rb', line 52 def list_item(item, description = nil) if description puts " âĸ #{@pastel.bold(item)} - #{description}" else puts " âĸ #{item}" end end |
#newline ⇒ Object
81 82 83 |
# File 'lib/sxn/ui/output.rb', line 81 def newline puts "" end |
#progress_done ⇒ Object
73 74 75 |
# File 'lib/sxn/ui/output.rb', line 73 def progress_done puts @pastel.green("â ") end |
#progress_failed ⇒ Object
77 78 79 |
# File 'lib/sxn/ui/output.rb', line 77 def progress_failed puts @pastel.red("â") end |
#progress_start(message) ⇒ Object
69 70 71 |
# File 'lib/sxn/ui/output.rb', line 69 def progress_start() print "#{}... " end |
#recovery_suggestion(message) ⇒ Object
85 86 87 88 |
# File 'lib/sxn/ui/output.rb', line 85 def recovery_suggestion() puts "" puts @pastel.yellow("đĄ Suggestion: #{}") end |
#section(title) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/sxn/ui/output.rb', line 38 def section(title) puts "" puts @pastel.bold(@pastel.cyan("â" * 60)) puts @pastel.bold(@pastel.cyan(" #{title}")) puts @pastel.bold(@pastel.cyan("â" * 60)) puts "" end |
#status(label, message, color = :blue) ⇒ Object
33 34 35 36 |
# File 'lib/sxn/ui/output.rb', line 33 def status(label, , color = :blue) colored_label = @pastel.public_send(color, "[#{label.upcase}]") puts "#{colored_label} #{}" end |
#subsection(title) ⇒ Object
46 47 48 49 50 |
# File 'lib/sxn/ui/output.rb', line 46 def subsection(title) puts "" puts @pastel.bold(title.to_s) puts @pastel.dim("â" * title.length) end |
#success(message) ⇒ Object
13 14 15 |
# File 'lib/sxn/ui/output.rb', line 13 def success() puts @pastel.green("â #{}") end |
#warning(message) ⇒ Object
21 22 23 |
# File 'lib/sxn/ui/output.rb', line 21 def warning() puts @pastel.yellow("â ī¸ #{}") end |