From bce5699be3d417be09696ed03dac56affa02c731 Mon Sep 17 00:00:00 2001 From: henrythebuilder Date: Fri, 18 Feb 2022 16:54:14 +0100 Subject: [PATCH 1/2] Handle 'mix local.rebar' command options without arguments --- lib/mix/lib/mix/tasks/local.rebar.ex | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/mix/lib/mix/tasks/local.rebar.ex b/lib/mix/lib/mix/tasks/local.rebar.ex index 295fc73c7a4..2ea6682eb5d 100644 --- a/lib/mix/lib/mix/tasks/local.rebar.ex +++ b/lib/mix/lib/mix/tasks/local.rebar.ex @@ -21,8 +21,6 @@ defmodule Mix.Tasks.Local.Rebar do ## Command line options - * `rebar PATH` - specifies a path for `rebar` - * `rebar3 PATH` - specifies a path for `rebar3` * `--sha512` - checks the Rebar script matches the given SHA-512 checksum @@ -44,9 +42,9 @@ defmodule Mix.Tasks.Local.Rebar do @impl true def run(argv) do - {opts, _, _} = OptionParser.parse(argv, switches: @switches) + {opts, args, _} = OptionParser.parse(argv, switches: @switches) - case argv do + case args do ["rebar3", path | _] -> maybe_install_from_path(:rebar3, path, opts) @@ -55,7 +53,7 @@ defmodule Mix.Tasks.Local.Rebar do _ -> Mix.raise( - "Invalid arguments given to mix local.rebar. " <> + "Invalid arguments given to mix local.rebar (#{inspect(args)}). " <> "To find out the proper call syntax run \"mix help local.rebar\"" ) end @@ -74,6 +72,13 @@ defmodule Mix.Tasks.Local.Rebar do end defp install_from_path(manager, path, opts) do + Mix.shell().info([ + :green, + "* installing Rebar locally ", + :reset, + "from #{inspect(path)} with options #{inspect(opts)}" + ]) + local = Mix.Rebar.local_rebar_path(manager) if opts[:force] || Mix.Generator.overwrite?(local) do From 58c3f54e63e536d0bf1783c592e946ab94984737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 18 Feb 2022 17:35:22 +0100 Subject: [PATCH 2/2] Apply suggestions from code review --- lib/mix/lib/mix/tasks/local.rebar.ex | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/mix/lib/mix/tasks/local.rebar.ex b/lib/mix/lib/mix/tasks/local.rebar.ex index 2ea6682eb5d..7774d206469 100644 --- a/lib/mix/lib/mix/tasks/local.rebar.ex +++ b/lib/mix/lib/mix/tasks/local.rebar.ex @@ -53,7 +53,7 @@ defmodule Mix.Tasks.Local.Rebar do _ -> Mix.raise( - "Invalid arguments given to mix local.rebar (#{inspect(args)}). " <> + "Invalid arguments given to mix local.rebar: #{inspect(args)}. " <> "To find out the proper call syntax run \"mix help local.rebar\"" ) end @@ -72,13 +72,6 @@ defmodule Mix.Tasks.Local.Rebar do end defp install_from_path(manager, path, opts) do - Mix.shell().info([ - :green, - "* installing Rebar locally ", - :reset, - "from #{inspect(path)} with options #{inspect(opts)}" - ]) - local = Mix.Rebar.local_rebar_path(manager) if opts[:force] || Mix.Generator.overwrite?(local) do