<commit_before>#!/usr/bin/env ruby
#  -*- encoding: utf-8 -*-

# List settings in current configuration

desc "ls [PAT]", "Display configuration information"
option "expand",   :aliases=>"-e", :type=>'boolean', :desc=>"Expand file settings"
def ls(pat=nil)
  config = Configuration.new
  config.read
  tasks = config.all_keys.sort
  pat ||= '*'
  pat = Bun.convert_glob(pat)
  selected_tasks = tasks.select {|task| task =~ pat }
  if selected_tasks.size > 0
    task_name_size = selected_tasks.map{|task| task.size}.max
    selected_tasks.each do |task|
      value = (options[:expand] && task =~ /_path$/) ? config.expanded_setting(task) : config.setting[task]
      puts "#{task.ljust(task_name_size)}  #{value}"
    end
  end
end<commit_msg>Refactor bun config ls<commit_after>#!/usr/bin/env ruby
#  -*- encoding: utf-8 -*-

# List settings in current configuration

desc "ls [PAT]", "Display configuration information"
option "expand",   :aliases=>"-e", :type=>'boolean', :desc=>"Expand file settings"
def ls(pat=nil)
  config = Configuration.new
  config.read
  tasks = config.all_keys.sort
  pat ||= '*'
  pat = Bun.convert_glob(pat)
  selected_tasks = tasks.select {|task| task =~ pat }
  if selected_tasks.size > 0
    table = [["Config","Setting"]] + selected_tasks.map do |task|
      [task, (options[:expand] && task =~ /_path$/) ? config.expanded_setting(task) : config.setting[task]]
    end
    puts table.justify_rows.map{|row| row.join('  ')}.join("\n")
  end
end
{'fraction_non_alphanumeric': 0.16700473292765383, 'fraction_numerical': 0.002704530087897228, 'mean_word_length': 4.051194539249146, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6790425', 'n_tokens_mistral': 514, 'n_tokens_neox': 501, 'n_words': 118}