File tree Expand file tree Collapse file tree 7 files changed +25
-8
lines changed Expand file tree Collapse file tree 7 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ Usage: $(basename "$0") [options] [.exs file] [data]
16
16
-pr "FILE" Requires the given files/patterns in parallel (*)
17
17
-pa "PATH" Prepends the given path to Erlang code path (*)
18
18
-pz "PATH" Appends the given path to Erlang code path (*)
19
- -v, --version Prints Erlang/OTP and Elixir versions
19
+ -v, --version Prints Erlang/OTP and Elixir versions (standalone)
20
20
21
21
--app APP Starts the given app and its dependencies (*)
22
22
--erl "SWITCHES" Switches to be passed down to Erlang (*)
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ echo -S SCRIPT Finds and executes the given script in $PATH
23
23
echo -pr " FILE" Requires the given files/patterns in parallel (*)
24
24
echo -pa " PATH" Prepends the given path to Erlang code path (*)
25
25
echo -pz " PATH" Appends the given path to Erlang code path (*)
26
- echo -v, --version Prints Erlang/OTP and Elixir versions
26
+ echo -v, --version Prints Erlang/OTP and Elixir versions (standalone)
27
27
echo .
28
28
echo --app APP Starts the given app and its dependencies (*)
29
29
echo --erl " SWITCHES" Switches to be passed down to Erlang (*)
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ Usage: $(basename "$0") [elixir switches] [compiler switches] [.ex files]
7
7
8
8
-h, --help Prints this message and exits
9
9
-o The directory to output compiled files
10
- -v, --version Prints Elixir version and exits
10
+ -v, --version Prints Elixir version and exits (standalone)
11
11
12
12
--ignore-module-conflict Does not emit warnings if a module was previously defined
13
13
--no-debug-info Does not attach debug info to compiled modules
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ echo Usage: %~nx0 [elixir switches] [compiler switches] [.ex files]
16
16
echo .
17
17
echo -h, --help Prints this message and exits
18
18
echo -o The directory to output compiled files
19
- echo -v, --version Prints Elixir version and exits
19
+ echo -v, --version Prints Elixir version and exits (standalone)
20
20
echo .
21
21
echo --ignore-module-conflict Does not emit warnings if a module was previously defined
22
22
echo --no-debug-info Does not attach debug info to compiled modules
Original file line number Diff line number Diff line change @@ -218,20 +218,25 @@ defmodule Kernel.CLI do
218
218
219
219
# Parse shared options
220
220
221
- defp parse_shared ( [ opt | _ ] , _config ) when opt in @ standalone_opts do
221
+ defp warn_standalone ( opt ) do
222
222
IO . puts ( :stderr , "#{ opt } : Standalone options can't be combined with other options" )
223
+ end
224
+
225
+ defp parse_shared ( [ opt | _ ] , _config ) when opt in @ standalone_opts do
226
+ warn_standalone ( opt )
223
227
System . halt ( 1 )
224
228
end
225
229
226
- defp parse_shared ( [ opt | t ] , config ) when opt in [ "-v" , "--version" ] do
230
+ defp parse_shared ( [ opt | t ] , _config ) when opt in [ "-v" , "--version" ] do
227
231
if function_exported? ( IEx , :started? , 0 ) and IEx . started? ( ) do
228
232
IO . puts ( "IEx " <> System . build_info ( ) [ :build ] )
229
233
else
230
234
IO . puts ( :erlang . system_info ( :system_version ) )
231
235
IO . puts ( "Elixir " <> System . build_info ( ) [ :build ] )
232
236
end
233
237
234
- parse_shared ( t , config )
238
+ t != [ ] && warn_standalone ( opt )
239
+ System . halt ( 1 )
235
240
end
236
241
237
242
defp parse_shared ( [ "-pa" , h | t ] , config ) do
Original file line number Diff line number Diff line change @@ -71,10 +71,14 @@ defmodule Kernel.CLITest do
71
71
assert output =~ "Erlang/OTP #{ System . otp_release ( ) } "
72
72
assert output =~ "Elixir #{ System . version ( ) } "
73
73
74
+ output = iex ( '--version' )
75
+ assert output =~ "Erlang/OTP #{ System . otp_release ( ) } "
76
+ assert output =~ "IEx #{ System . version ( ) } "
77
+
74
78
output = elixir ( '--version -e "IO.puts(:test_output)"' )
75
79
assert output =~ "Erlang/OTP #{ System . otp_release ( ) } "
76
80
assert output =~ "Elixir #{ System . version ( ) } "
77
- assert output =~ "test_output "
81
+ assert output =~ "Standalone options can't be combined with other options "
78
82
end
79
83
80
84
test "--short-version smoke test" do
Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ defmodule PathHelpers do
39
39
executable_path ( "elixirc" )
40
40
end
41
41
42
+ def iex ( args ) do
43
+ run_cmd ( iex_executable ( ) , args )
44
+ end
45
+
46
+ def iex_executable do
47
+ executable_path ( "iex" )
48
+ end
49
+
42
50
def write_beam ( { :module , name , bin , _ } = res ) do
43
51
File . mkdir_p! ( unquote ( path ) )
44
52
beam_path = Path . join ( unquote ( path ) , Atom . to_string ( name ) <> ".beam" )
You can’t perform that action at this time.
0 commit comments