@@ -10,15 +10,16 @@ defmodule Mix.Tasks.New do
10
10
Creates a new Elixir project.
11
11
It expects the path of the project as argument.
12
12
13
- mix new PATH [--sup ] [--module MODULE] [--umbrella]
13
+ mix new PATH [--bare ] [--module MODULE] [--umbrella]
14
14
15
15
A project at the given PATH will be created. The
16
16
application name and module name will be retrieved
17
17
from the path, unless `--module` is given.
18
18
19
- A `--sup` option can be given to generate an
20
- app with a supervisor and an application module
21
- that starts the supervisor.
19
+ A `--bare` option can be given to not generate an OTP
20
+ application skeleton. Normally an app is generated with
21
+ a supervisor and an application module that starts the
22
+ supervisor.
22
23
23
24
An `--umbrella` option can be given to generate an
24
25
umbrella project.
@@ -31,13 +32,13 @@ defmodule Mix.Tasks.New do
31
32
32
33
mix new hello_world --module HelloWorld
33
34
34
- To generate an app with supervisor and application behaviours:
35
+ To generate an app without supervisor and application behaviours:
35
36
36
- mix new hello_world --sup
37
+ mix new hello_world --bare
37
38
38
39
"""
39
40
def run ( argv ) do
40
- { opts , argv , _ } = OptionParser . parse ( argv , switches: [ sup : :boolean , umbrella: :boolean ] )
41
+ { opts , argv , _ } = OptionParser . parse ( argv , switches: [ bare : :boolean , umbrella: :boolean ] )
41
42
42
43
case argv do
43
44
[ ] ->
@@ -59,7 +60,7 @@ defmodule Mix.Tasks.New do
59
60
60
61
defp do_generate ( app , path , opts ) do
61
62
mod = opts [ :module ] || camelize ( app )
62
- otp_app = if opts [ :sup ] , do: "[mod: { #{ mod } , [] }]" , else: "[ ]"
63
+ otp_app = if opts [ :bare ] , do: "[]" , else: "[ mod: { #{ mod } , [] }]"
63
64
assigns = [ app: app , mod: mod , otp_app: otp_app ]
64
65
65
66
create_file "README.md" , readme_template ( assigns )
@@ -68,12 +69,12 @@ defmodule Mix.Tasks.New do
68
69
69
70
create_directory "lib"
70
71
71
- if opts [ :sup ] do
72
+ if opts [ :bare ] do
73
+ create_file "lib/#{ app } .ex" , lib_template ( assigns )
74
+ else
72
75
create_file "lib/#{ app } .ex" , lib_app_template ( assigns )
73
76
create_directory "lib/#{ app } "
74
77
create_file "lib/#{ app } /supervisor.ex" , lib_supervisor_template ( assigns )
75
- else
76
- create_file "lib/#{ app } .ex" , lib_template ( assigns )
77
78
end
78
79
79
80
create_directory "test"
0 commit comments