<commit_before>module Shashi
  module Command
    module SetSet

      def self.perform(file:, path:, key:, value:, force:)
        data = Utils.read_database(file: file)
        data_reference = Utils.data_walker(data: data, path: path)
        if data_reference.has_key?(key)
          if force
            update_data(file: file, data: data, data_reference: data_reference, key: key, value: value)
          else
            print "The key #{key} already exists at #{path.join(".")}, overwrite? [y/N] "
            choice = gets
            case choice.strip
            when "y"
              update_data(file: file, data: data, data_reference: data_reference, key: key, value: value)
            when ""
              # do nothing
            when "N"
              # do nothing
            else
              puts "Choice not understood, ignoring."
            end
          end
        else
          update_data(file: file, data: data, data_reference: data_reference, key: key, value: value)
        end
      end

      private

        def self.update_data(file:, data:, data_reference:, key:, value:)
          data_reference[key] = value
          Utils.write_database(file: file, data: data)
        end

    end
  end
end<commit_msg>handles the case where the value is not passed as a CLI parameter<commit_after>module Shashi
  module Command
    module SetSet

      def self.perform(file:, path:, key:, value:, force:)
        data = Utils.read_database(file: file)
        data_reference = Utils.data_walker(data: data, path: path)
        if data_reference.has_key?(key)
          if force
            update_data(file: file, data: data, data_reference: data_reference, key: key, value: value)
          else
            print "The key #{key} already exists at #{path.join(".")}, overwrite? [y/N] "
            choice = gets
            case choice.strip
            when "y"
              update_data(file: file, data: data, data_reference: data_reference, key: key, value: value)
            when ""
              # do nothing
            when "N"
              # do nothing
            else
              puts "Choice not understood, ignoring."
            end
          end
        else
          update_data(file: file, data: data, data_reference: data_reference, key: key, value: value)
        end
      end

      private

        def self.update_data(file:, data:, data_reference:, key:, value:)
          data_reference[key] = if value
            value
          else
            print "[#{key}] = "
            gets.strip
          end
          Utils.write_database(file: file, data: data)
        end

    end
  end
end
{'fraction_non_alphanumeric': 0.09241795548849491, 'fraction_numerical': 0.0, 'mean_word_length': 1.7769633507853404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1438066', 'n_tokens_mistral': 745, 'n_tokens_neox': 730, 'n_words': 230}