bin/demo in output_mode-1.2.2 vs bin/demo in output_mode-1.3.0

- old
+ new

@@ -25,10 +25,11 @@ # POSSIBILITY OF SUCH DAMAGE. #============================================================================== require "bundler/setup" require "output_mode" +require 'erb' module DemoIndex extend OutputMode::TLDR::Index register_callable(header: 'Integer', row_color: [:yellow, :bold]) { |i| i } @@ -45,17 +46,29 @@ register_callable(header: 'Integer') { |i| i } register_callable(header: 'Standard') { 'always visible' } register_callable(header: 'Verbose', verbose: true) { 'verbose visible' } register_callable(header: 'Simplified', verbose: false) { 'simplified visible' } - register_callable(header: 'Yes/True') { true } - register_callable(header: 'No/False') { false } + register_callable(header: 'Yes/True', section: :boolean) { true } + register_callable(header: 'No/False', section: :boolean) { false } register_callable(header: 'Missing') { nil } end data = [1, 2, 3] +other_template = ERB.new(<<~TEMPLATE, nil, '-') +# Non boolean values +<% each(:other) do |value, field:, padding:, **_| -%> +<%= padding -%><%= pastel.blue.bold field -%><%= pastel.bold ':' -%> <%= pastel.green value %> +<% end -%> + +# Boolean Values +<% each(:boolean) do |value, field:, padding:, **_| -%> +<%= padding -%><%= pastel.blue.bold field -%><%= pastel.bold ':' -%> <%= pastel.green value %> +<% end -%> +TEMPLATE + puts <<~EOF #============================================================================== #============================================================================== # INDEX OUTPUTS #============================================================================== @@ -120,6 +133,13 @@ #============================================================================== # Demo ASCII Index #============================================================================== #{DemoShow.build_output(ascii: true).render(*data)} + +#============================================================================== +# Group the boolean value separately +# NOTE: This only occurs in interactive mode +# Non-Interactive sessions have a fix order +#============================================================================== +#{DemoShow.build_output(template: other_template).render(*data)} EOF