<commit_before># encoding: utf-8
require "thor"
require "ldapam/config"
require "ldapam/connection"


module LDAPAM

  class CLI < Thor


    desc "showuids attribute value", "Replace the attribute for the uid"
    method_option :config, :type =>:string, :required =>true
    def find(attribute, value, *attributes)

      connection = Connection.new(Config.new(options[:config]))
      rs         = connection.read(attribute, value, attributes)
        
      abort("No entry results for the match: #{attribute}=#{value}") if rs.length == 0
      rs.each do |entry| 

        entry.attribute_names.each { |attr| puts "#{attr}: #{(entry[attr].length > 1) ? entry[attr].join(',') : entry[attr][0]}" }
      end
    rescue Exception =>exc
      abort("ERROR: #{exc.message}")
    end


    desc "update UID attribute value", "Replace the attribute for the uid"
    method_option :config, :type =>:string, :required =>true
    def update(uid, attribute, value)

      connection = Connection.new(Config.new(options[:config]))
      dn         = connection.uid2dn(uid)

      connection.update(dn, { attribute =>value }) 
    rescue Exception =>exc 
      abort("ERROR: #{exc.message}")
    end
  end
end<commit_msg>Fallo en la descripcion de un comando<commit_after># encoding: utf-8
require "thor"
require "ldapam/config"
require "ldapam/connection"


module LDAPAM

  class CLI < Thor


    desc "find attribute value", "Replace the attribute for the uid"
    method_option :config, :type =>:string, :required =>true
    def find(attribute, value, *attributes)

      connection = Connection.new(Config.new(options[:config]))
      rs         = connection.read(attribute, value, attributes)
        
      abort("No entry results for the match: #{attribute}=#{value}") if rs.length == 0
      rs.each do |entry| 

        entry.attribute_names.each { |attr| puts "#{attr}: #{(entry[attr].length > 1) ? entry[attr].join(',') : entry[attr][0]}" }
      end
    rescue Exception =>exc
      abort("ERROR: #{exc.message}")
    end


    desc "update UID attribute value", "Replace the attribute for the uid"
    method_option :config, :type =>:string, :required =>true
    def update(uid, attribute, value)

      connection = Connection.new(Config.new(options[:config]))
      dn         = connection.uid2dn(uid)

      connection.update(dn, { attribute =>value }) 
    rescue Exception =>exc 
      abort("ERROR: #{exc.message}")
    end
  end
end
{'fraction_non_alphanumeric': 0.13666121112929625, 'fraction_numerical': 0.004091653027823241, 'mean_word_length': 3.2374350086655115, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '7274180', 'n_tokens_mistral': 736, 'n_tokens_neox': 717, 'n_words': 213}