<commit_before># This is free and unencumbered software released into the public domain.

defmodule Foobar.CLI do
  @options [
    strict: [
      version: :boolean,
      help:    :boolean,
      quiet:   :boolean,
      verbose: :count,
      debug:   :boolean,
    ],
    aliases: [
      V: :version,
      h: :help,
      q: :quiet,
      v: :verbose,
      d: :debug,
    ],
  ]

  def main(argv \\ []) do
    argv |> parse_args |> process
  end

  defp parse_args(argv) do
    {_opts, _args, _ufos} = OptionParser.parse(argv, @options)
  end

  defp process({_, _, ufos}) when length(ufos) > 0 do
    IO.puts :stderr, "Invalid options: #{inspect ufos}"
  end

  defp process({[], [], []}) do
    IO.puts :stderr, "No options given."
    IO.puts :stderr, "No arguments given."
  end

  defp process({opts, [], []}) do
    IO.puts "Got options: #{inspect opts}"
    IO.puts :stderr, "No arguments given."
  end

  defp process({opts, args, []}) do
    IO.puts "Got options: #{inspect opts}"
    IO.puts "Got arguments: #{inspect args}"
  end
end<commit_msg>Implemented the --version and --help options.<commit_after># This is free and unencumbered software released into the public domain.

defmodule Foobar.CLI do
  alias Foobar.Mixfile

  @app     Keyword.fetch!(Mixfile.project, :app)
  @name    Keyword.fetch!(Mixfile.project, :name)
  @version Keyword.fetch!(Mixfile.project, :version)
  @options [
    strict: [
      version: :boolean,
      help:    :boolean,
      quiet:   :boolean,
      verbose: :count,
      debug:   :boolean,
    ],
    aliases: [
      V: :version,
      h: :help,
      q: :quiet,
      v: :verbose,
      d: :debug,
    ],
  ]

  def main(argv \\ []) do
    argv |> parse_args |> process
  end

  defp parse_args(argv) do
    {opts, args, ufos} = OptionParser.parse(argv, @options)
    {Enum.into(opts, %{}), args, ufos}
  end

  defp process({_, _, ufos}) when length(ufos) > 0 do
    IO.puts :stderr, "#{@app}: Unknown options: #{inspect ufos}"
  end

  defp process({[], [], []}) do
    IO.puts :stderr, "#{@app}: No options given."
    IO.puts :stderr, "#{@app}: No arguments given."
  end

  defp process({%{version: true}, _, _}) do
    IO.puts "#{@name} #{@version}"
  end

  defp process({%{help: true}, _, _}) do
    help
  end

  defp process({opts, [], []}) do
    IO.puts "Got options: #{inspect opts}"
    IO.puts :stderr, "#{@app}: No arguments given."
  end

  defp process({opts, args, []}) do
    IO.puts "Got options: #{inspect opts}"
    IO.puts "Got arguments: #{inspect args}"
  end

  defp help do
    IO.puts "Usage: #{@app} [-Vhqvd] [arguments...]"
    IO.puts ""
  end
end
{'fraction_non_alphanumeric': 0.16040955631399317, 'fraction_numerical': 0.0007584376185058779, 'mean_word_length': 2.6588072122052706, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6931991', 'n_tokens_mistral': 974, 'n_tokens_neox': 940, 'n_words': 270}