<commit_before>module Fission
  class CLI
    def self.execute(args=ARGV)
      optparse = OptionParser.new do |opts|
        opts.banner = "\nUsage: fission [options] COMMAND [arguments]"

        opts.on_head('-v', '--version', 'Output the version of fission') do
          Fission.ui.output Fission::VERSION
          exit(0)
        end

        opts.on_head('-h', '--help', 'Displays this message') do
          show_all_help(optparse)
          exit(0)
        end

        opts.define_tail do
          commands_banner
        end

      end

      begin
        optparse.order! args
      rescue OptionParser::InvalidOption => e
        Fission.ui.output e
        show_all_help(optparse)
        exit(1)
      end

      if commands.include?(args.first)
        @cmd = Fission::Command.const_get(args.first.capitalize).new args.drop 1
        @cmd.execute
      else
        show_all_help(optparse)
        exit(0)
      end
    end

    def self.commands
      cmds = []
      Dir.entries(File.join(File.dirname(__FILE__), 'command')).select do |file|
        cmds << File.basename(file, '.rb') unless File.directory? file
      end

      cmds
    end

    private
    def self.commands_banner
      text = "\nCommands:\n"<commit_msg>exit with an error for an unknown command<commit_after>module Fission
  class CLI
    def self.execute(args=ARGV)
      optparse = OptionParser.new do |opts|
        opts.banner = "\nUsage: fission [options] COMMAND [arguments]"

        opts.on_head('-v', '--version', 'Output the version of fission') do
          Fission.ui.output Fission::VERSION
          exit(0)
        end

        opts.on_head('-h', '--help', 'Displays this message') do
          show_all_help(optparse)
          exit(0)
        end

        opts.define_tail do
          commands_banner
        end

      end

      begin
        optparse.order! args
      rescue OptionParser::InvalidOption => e
        Fission.ui.output e
        show_all_help(optparse)
        exit(1)
      end

      if commands.include?(args.first)
        @cmd = Fission::Command.const_get(args.first.capitalize).new args.drop 1
        @cmd.execute
      else
        show_all_help(optparse)
        exit(1)
      end
    end

    def self.commands
      cmds = []
      Dir.entries(File.join(File.dirname(__FILE__), 'command')).select do |file|
        cmds << File.basename(file, '.rb') unless File.directory? file
      end

      cmds
    end

    private
    def self.commands_banner
      text = "\nCommands:\n"
{'fraction_non_alphanumeric': 0.10405083399523431, 'fraction_numerical': 0.003971405877680699, 'mean_word_length': 1.963529411764706, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '7513498', 'n_tokens_mistral': 792, 'n_tokens_neox': 763, 'n_words': 178}