<commit_before>require 'optparse'

module Praefect
  EXEC_PATH = '/opt/gitlab/embedded/bin/praefect'.freeze
  DIR_PATH = '/var/opt/gitlab/praefect'.freeze

  USAGE ||= <<~EOS.freeze
    Usage:
      gitlab-ctl praefect command [options]

    COMMANDS:
      remove-repository           Remove repository from Gitaly cluster
      track-repository            Tells Gitaly cluster to track a repository
      list-untracked-repositories Lists repositories that exist on disk but are untracked by Praefect
  EOS

  def self.parse_options!(args)
    loop do
      break if args.shift == 'praefect'
    end

    global = OptionParser.new do |opts|
      opts.on('-h', '--help', 'Usage help') do
        Kernel.puts USAGE
        Kernel.exit 0
      end
    end

    options = {}
    commands = {
      'remove-repository' => OptionParser.new do |opts|
        opts.banner = "Usage: gitlab-ctl praefect remove-repository [options]"

        parse_common_options!(options, opts)
        parse_repository_options!(options, opts)
      end,

      'track-repository' => OptionParser.new do |opts|
        opts.banner = "Usage: gitlab-ctl praefect track-repository [options]"

        parse_common_options!(options, opts)
        parse_repository_options!(options, opts)

        opts.on('--authoritative-storage STORAGE-NAME', 'The storage to use as the primary for this repository (optional)') do |authoritative_storage|
          options[:authoritative_storage] = authoritative_storage
        end
      end,

      'list-untracked-repositories' => OptionParser.new do |opts|
        opts.banner = "Usage: gitlab-ctl praefect untracked-repositories [options]"

        parse_common_options!(options, opts)
      end
    }

    global.order!(args)
<commit_msg>Clarify that `authoritative_storage` flag is required for Praefect's track-repository command when per_repository election is used<commit_after>require 'optparse'

module Praefect
  EXEC_PATH = '/opt/gitlab/embedded/bin/praefect'.freeze
  DIR_PATH = '/var/opt/gitlab/praefect'.freeze

  USAGE ||= <<~EOS.freeze
    Usage:
      gitlab-ctl praefect command [options]

    COMMANDS:
      remove-repository           Remove repository from Gitaly cluster
      track-repository            Tells Gitaly cluster to track a repository
      list-untracked-repositories Lists repositories that exist on disk but are untracked by Praefect
  EOS

  def self.parse_options!(args)
    loop do
      break if args.shift == 'praefect'
    end

    global = OptionParser.new do |opts|
      opts.on('-h', '--help', 'Usage help') do
        Kernel.puts USAGE
        Kernel.exit 0
      end
    end

    options = {}
    commands = {
      'remove-repository' => OptionParser.new do |opts|
        opts.banner = "Usage: gitlab-ctl praefect remove-repository [options]"

        parse_common_options!(options, opts)
        parse_repository_options!(options, opts)
      end,

      'track-repository' => OptionParser.new do |opts|
        opts.banner = "Usage: gitlab-ctl praefect track-repository [options]"

        parse_common_options!(options, opts)
        parse_repository_options!(options, opts)

        opts.on('--authoritative-storage STORAGE-NAME', 'The storage to use as the primary for this repository (mandatory for per_repository elector)') do |authoritative_storage|
          options[:authoritative_storage] = authoritative_storage
        end
      end,

      'list-untracked-repositories' => OptionParser.new do |opts|
        opts.banner = "Usage: gitlab-ctl praefect untracked-repositories [options]"

        parse_common_options!(options, opts)
      end
    }

    global.order!(args)

{'fraction_non_alphanumeric': 0.09482049876678542, 'fraction_numerical': 0.0005480953685941354, 'mean_word_length': 2.8542766631467793, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3941556', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1055, 'n_words': 279}