<commit_before>require 'thor'
require 'etc'
require 'yaml'
require 'fuzzy_match'
require 'pry'

module GIF
  class CLI < Thor
    desc "setup OPTIONS", "Set the options for gif"
    option :directory
    option :prefix
    def setup
      config['directory'] = options[:directory] 
      config['prefix'] = options[:prefix] 
      save_settings
    end
    
    desc "random", "Get a random GIF"
    def random
      gif = all_gifs.sample
      copy_to_clipboard url_for(gif)
      say "Copied URL for #{gif} to your clipboard"
    end

    desc "search STRING", "Search for a GIF"
    def search(string)
      gifs = FuzzyMatch.new(all_gifs)
      gif = gifs.find(string)
      
      if gif
        copy_to_clipboard url_for(gif)
        say "Found #{gif}. Copied URL to clipboard."
      end
    end

    private
    def all_gifs
      Dir["#{gif_directory}/**/*.gif"].map{|path| path.gsub(gif_directory + "/", '')  } 
    end
<commit_msg>List all gifs<commit_after>require 'thor'
require 'etc'
require 'yaml'
require 'fuzzy_match'
require 'pry'

module GIF
  class CLI < Thor
    desc "setup OPTIONS", "Set the options for gif"
    option :directory
    option :prefix
    def setup
      config['directory'] = options[:directory] 
      config['prefix'] = options[:prefix] 
      save_settings
    end
    
    desc "random", "Get a random GIF"
    def random
      gif = all_gifs.sample
      copy_to_clipboard url_for(gif)
      say "Copied URL for #{gif} to your clipboard"
    end

    desc "search STRING", "Search for a GIF"
    def search(string)
      gifs = FuzzyMatch.new(all_gifs)
      gif = gifs.find(string)
      
      if gif
        copy_to_clipboard url_for(gif)
        say "Found #{gif}. Copied URL to clipboard."
      end
    end

    desc "list", "List all your GIFs"
    def list
      say all_gifs.join("\n")
    end

    private
    def all_gifs
      Dir["#{gif_directory}/**/*.gif"].map{|path| path.gsub(gif_directory + "/", '')  } 
    end

{'fraction_non_alphanumeric': 0.1099290780141844, 'fraction_numerical': 0.0, 'mean_word_length': 2.458844133099825, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1594490', 'n_tokens_mistral': 676, 'n_tokens_neox': 650, 'n_words': 189}