Skip to content

Commit cf6751a

Browse files
author
José Valim
committed
Merge pull request #844 from michaelklishin/issue843
Make Mix support --help, -h and -help
2 parents 5557e62 + 42a0719 commit cf6751a

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

lib/mix/lib/mix/cli.ex

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,11 @@ defmodule Mix.CLI do
55
Runs Mix according to the command line arguments.
66
"""
77
def run(args // System.argv) do
8-
Mix.Local.append_tasks
9-
10-
args = load_mixfile(args)
11-
{ task, args } = get_task(args)
12-
13-
if Mix.Project.get do
14-
Mix.Task.run "loadpaths", ["--no-check"]
15-
Mix.Task.reenable "loadpaths"
16-
Mix.Task.reenable "deps.loadpaths"
8+
if help?(args) do
9+
display_banner()
10+
else
11+
proceed(args)
1712
end
18-
19-
run_task task, args
2013
end
2114

2215
defp load_mixfile(args) do
@@ -54,4 +47,26 @@ defmodule Mix.CLI do
5447
end
5548
end
5649
end
50+
51+
defp proceed(args) do
52+
Mix.Local.append_tasks
53+
54+
args = load_mixfile(args)
55+
{ task, args } = get_task(args)
56+
57+
if Mix.Project.get do
58+
Mix.Task.run "loadpaths", ["--no-check"]
59+
Mix.Task.reenable "loadpaths"
60+
Mix.Task.reenable "deps.loadpaths"
61+
end
62+
63+
run_task task, args
64+
end
65+
66+
defp display_banner() do
67+
run_task "help", []
68+
end
69+
70+
defp help?([first_arg|_]) when first_arg in ["--help", "-h", "-help"], do: true
71+
defp help?(_), do: false
5772
end

0 commit comments

Comments
 (0)