<commit_before>require 'arg_parser'
require 'config'
require 'file_util'

module MScript
  class Executor
    def initialize()
      @file_util = MScript::FileUtil.new
      @arg_parser = MScript::ArgParser.new
    end
    
    def execute(args)
      config = MScript::Config.new(@file_util.locate_project_directory(File.expand_path('.')))
      builds = @arg_parser.parse(args)
      
      total_builds = builds['projects'].length
      
      commands = []
      builds['projects'].each do |project|
        directory_alias = project['project']
        phase_aliases = project['phases']
        
        commands << "mvn #{config.to_phases(phase_aliases).join(' ')} -f #{File.join(config.to_directory(directory_alias), 'pom.xml')} #{builds['arguments']}"
      end
      
      # was done this way because Control+C does not kill all builds?? WTF?!
      command = commands.join(' && ')
      
      puts "------------------------------"
      puts "M Script Running....#{total_builds} build(s)" 
      puts "------------------------------"
      puts "#{command}"
      puts "------------------------------\n"
      
      system command
      
    end
    
    def show_help()
      config = MScript::Config.new(@file_util.locate_project_directory(File.expand_path('.')))
      
      puts "\n"
      puts "Project Directory: #{config.project_directory}\n\n"
      puts "Directory to Alias(es):\n---------------------------\n"
      
      longest_name = ""
      config.directory_aliases.each do |key, value|
        if (key.length > longest_name.length)
          longest_name = key
        end
      end
      
      config.directory_aliases.each do |key, value|
        number_of_dots = longest_name.length + 2 - key.length
        count = 0
        dots = ""
        while count < number_of_dots
          dots += "."
          count += 1
        end
        puts "#{key}#{dots}#{value.join(', ')}\n"
      end
      puts "\nAvailable Phase(s):\n---------------------------\n"
      config.phases.each do |key, value|
        puts "#{key}....#{value}"
      end<commit_msg>updated to sort the folders alphabetically in the help<commit_after>require 'arg_parser'
require 'config'
require 'file_util'

module MScript
  class Executor
    def initialize()
      @file_util = MScript::FileUtil.new
      @arg_parser = MScript::ArgParser.new
    end
    
    def execute(args)
      config = MScript::Config.new(@file_util.locate_project_directory(File.expand_path('.')))
      builds = @arg_parser.parse(args)
      
      total_builds = builds['projects'].length
      
      commands = []
      builds['projects'].each do |project|
        directory_alias = project['project']
        phase_aliases = project['phases']
        
        commands << "mvn #{config.to_phases(phase_aliases).join(' ')} -f #{File.join(config.to_directory(directory_alias), 'pom.xml')} #{builds['arguments']}"
      end
      
      # was done this way because Control+C does not kill all builds?? WTF?!
      command = commands.join(' && ')
      
      puts "------------------------------"
      puts "M Script Running....#{total_builds} build(s)" 
      puts "------------------------------"
      puts "#{command}"
      puts "------------------------------\n"
      
      system command
      
    end
    
    def show_help()
      config = MScript::Config.new(@file_util.locate_project_directory(File.expand_path('.')))
      
      puts "\n"
      puts "Project Directory: #{config.project_directory}\n\n"
      puts "Directory to Alias(es):\n---------------------------\n"
      
      longest_name = ""
      names = []
      config.directory_aliases.each do |key, value|
        if (key.length > longest_name.length)
          longest_name = key
        end
        names << key
      end
      
      names.sort { |a, b| a <=> b}.each do |directory|
        aliases = config.directory_aliases[directory]
        number_of_dots = longest_name.length + 2 - directory.length
        count = 0
        dots = ""
        while count < number_of_dots
          dots += "."
          count += 1
        end
        puts "#{directory}#{dots}#{aliases.join(', ')}\n"
      end
      
      puts "\nAvailable Phase(s):\n---------------------------\n"
      config.phases.each do |key, value|
        puts "#{key}....#{value}"
      end
{'fraction_non_alphanumeric': 0.19005780346820808, 'fraction_numerical': 0.0013872832369942196, 'mean_word_length': 1.7713004484304933, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4069171', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1268, 'n_words': 269}