def list_items(glob_pattern, options = {})
      list  = { 0 => 'Exit' }
      index = 1
      raw_list = { 0 => 'Exit' }

      Dir[glob_pattern.to_s].each do |elem|
        #puts "=> element '#{elem}' - dir = #{File.directory?(elem)}; file = #{File.file?(elem)}"
        next if (!options[:only_files].nil?) && options[:only_files] && File.directory?(elem)
        next if (!options[:only_dirs].nil?)  && options[:only_dirs]  && File.file?(elem)
        entry = File.basename(elem)
        # unless options[:pattern_include].nil?
        #     select_entry = false
        #     options[:pattern_include].each do |pattern|
        #         #puts "considering pattern '#{pattern}' on entry '#{entry}'"
        #         select_entry |= entry =~ /#{pattern}/
        #     end
        #     next unless select_entry
        # end
        unless options[:pattern_exclude].nil?
          select_entry = false
          options[:pattern_exclude].each do |pattern|
            #puts "considering pattern '#{pattern}' on entry '#{entry}'"
            select_entry |= entry =~ /#{pattern}/
          end
          next if select_entry
        end
        #puts "selected entry = '#{entry}'"
        list[index]     = entry
        raw_list[index] = elem
        index += 1
      end
      text        = (options[:text].nil?)    ? "select the index" : options[:text]
      default_idx = (options[:default].nil?) ? 0 : options[:default]
      raise SystemExit, 'Empty list' if index == 1
      #ap list
      #ap raw_list
      # puts list.to_yaml
      # answer = ask("=> #{text}", "#{default_idx}")
      # raise SystemExit.new('exiting selection') if answer == '0'
      # raise RangeError.new('Undefined index')   if Integer(answer) >= list.length
      # raw_list[Integer(answer)]
      select_from(list, text, default_idx, raw_list)
    end
def list_items(glob_pattern, options = {})
      list  = { 0 => 'Exit' }
      index = 1
      raw_list = { 0 => 'Exit' }

      Dir[glob_pattern.to_s].each do |elem|
        #puts "=> element '#{elem}' - dir = #{File.directory?(elem)}; file = #{File.file?(elem)}"
        next if (!options[:only_files].nil?) && options[:only_files] && File.directory?(elem)
        next if (!options[:only_dirs].nil?)  && options[:only_dirs]  && File.file?(elem)
        entry = File.basename(elem)
        # unless options[:pattern_include].nil?
        #     select_entry = false
        #     options[:pattern_include].each do |pattern|
        #         #puts "considering pattern '#{pattern}' on entry '#{entry}'"
        #         select_entry |= entry =~ /#{pattern}/
        #     end
        #     next unless select_entry
        # end
        unless options[:pattern_exclude].nil?
          select_entry = false
          options[:pattern_exclude].each do |pattern|
            #puts "considering pattern '#{pattern}' on entry '#{entry}'"
            select_entry |= entry =~ /#{pattern}/
          end
          next if select_entry
        end
        #puts "selected entry = '#{entry}'"
        list[index]     = entry
        raw_list[index] = elem
        index += 1
      end
      text        = (options[:text].nil?)    ? "select the index" : options[:text]
      default_idx = (options[:default].nil?) ? 0 : options[:default]
      raise SystemExit, 'Empty list' if index == 1
      #ap list
      #ap raw_list
      # puts list.to_yaml
      # answer = ask("=> #{text}", "#{default_idx}")
      # raise SystemExit.new('exiting selection') if answer == '0'
      # raise RangeError.new('Undefined index')   if Integer(answer) >= list.length
      # raw_list[Integer(answer)]
      select_from(list, text, default_idx, raw_list)
    end
List items from a glob pattern to ask for a unique choice
 Supported options:
   :only_files      [boolean]: list only files in the glob
   :only_dirs       [boolean]: list only directories in the glob
   :pattern_include [array of strings]: pattern(s) to include for listing
   :pattern_exclude [array of strings]: pattern(s) to exclude for listing
   :text            [string]: text to put