<commit_before># frozen_string_literal: true

module DeepCover
  class CLI
    # Thor comes with a built-in help command. When displaying full help, it calls the class' help
    # We override it to make it more to our taste.

    # Copied from Thor's default one, then customized
    def help(shell, subcommand = false)
      list = printable_commands(true, subcommand)
      Thor::Util.thor_classes_in(self).each do |klass|
        list += klass.printable_commands(false)
      end
      list.sort! { |a, b| a[0] <=> b[0] }

      if defined?(@package_name) && @package_name
        shell.say "#{@package_name} commands:"
      else
        shell.say 'Commands:'
      end

      shell.print_table(list, indent: 2, truncate: true)
      shell.say
      class_options_help(shell)
    end<commit_msg>Split commands in help into sections<commit_after># frozen_string_literal: true

module DeepCover
  class CLI
    # Thor comes with a built-in help command. When displaying full help, it calls the class' help
    # We override it to make it more to our taste.

    # Copied from Thor's default one, then customized
    def self.help(shell, subcommand = false)
      list = printable_commands(true, subcommand)
      Thor::Util.thor_classes_in(self).each do |klass|
        list += klass.printable_commands(false)
      end
      list.sort! { |a, b| a[0] <=> b[0] }

      main_commands, list = extract_commands_for_help(list, :exec, :clone)

      shell.say 'Main commands:'
      shell.print_table(main_commands, indent: 2, truncate: true)

      lower_level_commands, list = extract_commands_for_help(list, :gather, :report, :clear, :merge)
      shell.say
      shell.say 'Lower-level commands:'
      shell.print_table(lower_level_commands, indent: 2, truncate: true)

      shell.say
      shell.say 'Misc commands:'
      shell.print_table(list, indent: 2, truncate: true)

      shell.say
      class_options_help(shell)
    end

    # Extracts the commands for the help by name, in same order as the names.
    # Returns the matching and the remaining commands.
    def self.extract_commands_for_help(commands, *names)
      matching = names.map do |name|
        commands.detect { |usage, desc| usage.start_with?("deep-cover #{name}") }
      end
      remains = commands - matching
      [matching, remains]
    end
{'fraction_non_alphanumeric': 0.0963855421686747, 'fraction_numerical': 0.0034423407917383822, 'mean_word_length': 3.0364583333333335, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6688181', 'n_tokens_mistral': 718, 'n_tokens_neox': 699, 'n_words': 219}