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]
1616 -pr "FILE" Requires the given files/patterns in parallel (*)
1717 -pa "PATH" Prepends the given path to Erlang code path (*)
1818 -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)
2020
2121 --app APP Starts the given app and its dependencies (*)
2222 --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
2323echo -pr " FILE" Requires the given files/patterns in parallel (*)
2424echo -pa " PATH" Prepends the given path to Erlang code path (*)
2525echo -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)
2727echo .
2828echo --app APP Starts the given app and its dependencies (*)
2929echo --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]
77
88 -h, --help Prints this message and exits
99 -o The directory to output compiled files
10- -v, --version Prints Elixir version and exits
10+ -v, --version Prints Elixir version and exits (standalone)
1111
1212 --ignore-module-conflict Does not emit warnings if a module was previously defined
1313 --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]
1616echo .
1717echo -h, --help Prints this message and exits
1818echo -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)
2020echo .
2121echo --ignore-module-conflict Does not emit warnings if a module was previously defined
2222echo --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
218218
219219 # Parse shared options
220220
221- defp parse_shared ( [ opt | _ ] , _config ) when opt in @ standalone_opts do
221+ defp warn_standalone ( opt ) do
222222 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 )
223227 System . halt ( 1 )
224228 end
225229
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
227231 if function_exported? ( IEx , :started? , 0 ) and IEx . started? ( ) do
228232 IO . puts ( "IEx " <> System . build_info ( ) [ :build ] )
229233 else
230234 IO . puts ( :erlang . system_info ( :system_version ) )
231235 IO . puts ( "Elixir " <> System . build_info ( ) [ :build ] )
232236 end
233237
234- parse_shared ( t , config )
238+ t != [ ] && warn_standalone ( opt )
239+ System . halt ( 1 )
235240 end
236241
237242 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
7171 assert output =~ "Erlang/OTP #{ System . otp_release ( ) } "
7272 assert output =~ "Elixir #{ System . version ( ) } "
7373
74+ output = iex ( '--version' )
75+ assert output =~ "Erlang/OTP #{ System . otp_release ( ) } "
76+ assert output =~ "IEx #{ System . version ( ) } "
77+
7478 output = elixir ( '--version -e "IO.puts(:test_output)"' )
7579 assert output =~ "Erlang/OTP #{ System . otp_release ( ) } "
7680 assert output =~ "Elixir #{ System . version ( ) } "
77- assert output =~ "test_output "
81+ assert output =~ "Standalone options can't be combined with other options "
7882 end
7983
8084 test "--short-version smoke test" do
Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ defmodule PathHelpers do
3939 executable_path ( "elixirc" )
4040 end
4141
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+
4250 def write_beam ( { :module , name , bin , _ } = res ) do
4351 File . mkdir_p! ( unquote ( path ) )
4452 beam_path = Path . join ( unquote ( path ) , Atom . to_string ( name ) <> ".beam" )
You can’t perform that action at this time.
0 commit comments