       end
 
     dir = dir || @default_dir
+    switches = switches_kw |> Enum.into(%{})
     config = dir |> to_config(switches)
 
     command_name_dir_config(command_name, args, config)

  end

  defp parse_options(argv) do
    {switches, args, []} =
      OptionParser.parse(argv, switches: @switches, aliases: @aliases)

    {command_name, dir} =

  end

  defp to_config(dir, switches) do
    dir
    |> Filename.remove_line_no_and_column
    |> Config.read_or_default(switches[:config_name])
    |> set_all(switches)
    |> set_crash_on_error(switches)
    |> set_deprecated_switches(switches)
    |> set_format(switches)
    |> set_help(switches)
    |> set_ignore(switches)
    |> set_min_priority(switches)
    |> set_only(switches)
    |> set_read_from_stdin(switches)
    |> set_strict(switches)
    |> set_verbose(switches)
    |> set_version(switches)
  end

  defp set_all(config, %{all: true}) do
    %Config{config | all: true}
  end
  defp set_all(config, _), do: config

  defp set_strict(config, %{all_priorities: true}) do
    set_strict(config, %{strict: true})
  end
  defp set_strict(config, %{strict: true}) do
    %Config{config | all: true, min_priority: -99}
  end
  defp set_strict(config, _), do: config

  defp set_help(config, %{help: true}) do
    %Config{config | help: true}
  end
  defp set_help(config, _), do: config

  defp set_verbose(config, %{verbose: true}) do
    %Config{config | verbose: true}
  end
  defp set_verbose(config, _), do: config

  defp set_crash_on_error(config, %{crash_on_error: true}) do
    %Config{config | crash_on_error: true}
  end
  defp set_crash_on_error(config, _), do: config

  defp set_read_from_stdin(config, %{read_from_stdin: true}) do
    %Config{config | read_from_stdin: true}
  end
  defp set_read_from_stdin(config, _), do: config

  defp set_version(config, %{version: true}) do
    %Config{config | version: true}
  end
  defp set_version(config, _), do: config

  defp set_format(config, %{format: format}) do
    %Config{config | format: format}
  end
  defp set_format(config, _), do: config

  defp set_min_priority(config, %{min_priority: min_priority}) do
    %Config{config | min_priority: min_priority}
  end
  defp set_min_priority(config, _), do: config

  # exclude/ignore certain checks
  defp set_only(config, %{only: only}) do
    set_only(config, %{checks: only})
  end
  defp set_only(config, %{checks: check_pattern}) do
    %Config{config | all: true, min_priority: -99,
                      match_checks: check_pattern |> String.split(",")}
  end
  defp set_only(config, _), do: config

  # exclude/ignore certain checks
  defp set_ignore(config, %{ignore: ignore}) do
    set_ignore(config, %{ignore_checks: ignore})
  end
  defp set_ignore(config, %{ignore_checks: ignore_pattern}) do
    %Config{config | ignore_checks: ignore_pattern |> String.split(",")}
  end
  defp set_ignore(config, _), do: config

  # DEPRECATED command line switches
  defp set_deprecated_switches(config, %{one_line: true}) do
    UI.puts [:yellow, "[DEPRECATED] ", :faint, "--one-line is deprecated in favor of --format=oneline"]
    %Config{config | format: "oneline"}
  end
  defp set_deprecated_switches(config, _), do: config

  # Converts the return value of a Command.run() call into an exit_status
  defp to_exit_status(:ok), do: 0
