<commit_before>defmodule Mix.CLI do
  @moduledoc false

  @doc """
  Runs Mix according to the command line arguments.
  """
  def main(args \\ System.argv) do
    Mix.Local.append_archives
    Mix.Local.append_paths

    if env_variable_activated?("MIX_QUIET"), do: Mix.shell(Mix.Shell.Quiet)
    if env_variable_activated?("MIX_DEBUG"), do: Mix.debug(true)

    case check_for_shortcuts(args) do
      :help ->
        proceed(["help"])
      :version ->
        display_version()
      nil ->
        proceed(args)
    end
  end

  defp proceed(args) do
    load_dot_config()
    load_mixfile()
    {task, args} = get_task(args)
    ensure_hex(task)
    change_env(task)
    run_task(task, args)
  end

  defp load_mixfile() do
    file = System.get_env("MIX_EXS") || "mix.exs"
    _ = if File.regular?(file) do
      Code.load_file(file)
    end
  end

  defp get_task(["-" <> _ | _]) do
    Mix.shell.error "** (Mix) Mix requires a task name when passing flags, " <>
                    "try invoking \"mix #{Mix.Project.config[:default_task]}\" instead"
    exit({:shutdown, 1})
  end

  defp get_task([h | t]) do
    {h, t}
  end

  defp get_task([]) do
    case Mix.Project.get do
      nil ->
        Mix.shell.error "** (Mix) \"mix\" with no arguments must be executed in a directory with a mix.exs file"
        Mix.shell.info """

        Usage: mix [task]

        Examples:

            mix             - Invokes the default task (current: "mix run")
            mix new         - Creates a new Elixir project
            mix help        - Lists all available tasks
            mix help TASK   - Prints documentation for a given task
        """
        exit({:shutdown, 1})
      _ ->
        {Mix.Project.config[:default_task], []}
    end
  end

  defp run_task(name, args) do
    try do
      ensure_no_slashes(name)
      Mix.Task.run "loadconfig"
      Mix.Task.run name, args<commit_msg>Correct "mix new" command message in Mix.CLI (#6004)<commit_after>defmodule Mix.CLI do
  @moduledoc false

  @doc """
  Runs Mix according to the command line arguments.
  """
  def main(args \\ System.argv) do
    Mix.Local.append_archives
    Mix.Local.append_paths

    if env_variable_activated?("MIX_QUIET"), do: Mix.shell(Mix.Shell.Quiet)
    if env_variable_activated?("MIX_DEBUG"), do: Mix.debug(true)

    case check_for_shortcuts(args) do
      :help ->
        proceed(["help"])
      :version ->
        display_version()
      nil ->
        proceed(args)
    end
  end

  defp proceed(args) do
    load_dot_config()
    load_mixfile()
    {task, args} = get_task(args)
    ensure_hex(task)
    change_env(task)
    run_task(task, args)
  end

  defp load_mixfile() do
    file = System.get_env("MIX_EXS") || "mix.exs"
    _ = if File.regular?(file) do
      Code.load_file(file)
    end
  end

  defp get_task(["-" <> _ | _]) do
    Mix.shell.error "** (Mix) Mix requires a task name when passing flags, " <>
                    "try invoking \"mix #{Mix.Project.config[:default_task]}\" instead"
    exit({:shutdown, 1})
  end

  defp get_task([h | t]) do
    {h, t}
  end

  defp get_task([]) do
    case Mix.Project.get do
      nil ->
        Mix.shell.error "** (Mix) \"mix\" with no arguments must be executed in a directory with a mix.exs file"
        Mix.shell.info """

        Usage: mix [task]

        Examples:

            mix             - Invokes the default task (current: "mix run")
            mix new PATH    - Creates a new Elixir project at the given path
            mix help        - Lists all available tasks
            mix help TASK   - Prints documentation for a given task
        """
        exit({:shutdown, 1})
      _ ->
        {Mix.Project.config[:default_task], []}
    end
  end

  defp run_task(name, args) do
    try do
      ensure_no_slashes(name)
      Mix.Task.run "loadconfig"
      Mix.Task.run name, args
{'fraction_non_alphanumeric': 0.11773818745158791, 'fraction_numerical': 0.0020655822359927703, 'mean_word_length': 2.178014766201805, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '4855267', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1259, 'n_words': 345}