From 4b6307de106da2874dea7508d43110ae4bc02751 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Date: Mon, 18 May 2020 14:53:33 +0200 Subject: [PATCH] B #687: filter by hidden columns --- src/cli/cli_helper.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index f2b4329824..b223d7c21e 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -571,8 +571,8 @@ module CLIHelper # @return [Array] Array with selected columns information def data_array(data, options) res_data = data.collect do |d| - @columns.collect do |_, params| - params[:proc].call(d).to_s + @default_columns.collect do |c| + @columns[c][:proc].call(d).to_s if @columns[c] end end @@ -580,6 +580,10 @@ module CLIHelper filter_data!(res_data, options) if options[:filter] end + return res_data unless options[:list] + + @default_columns = options[:list].collect {|o| o.upcase.to_sym } + res_data end @@ -797,10 +801,6 @@ module CLIHelper rescue StandardError => e CLIHelper.fail(e.message) end - - return unless options[:list] - - @default_columns = options[:list].collect {|o| o.upcase.to_sym } end # Filter data