Skip to content

Commit 31b4290

Browse files
author
José Valim
committed
Add IEx processing to Kernel.CLI
1 parent 39c33c7 commit 31b4290

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

bin/elixirc

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ readlink_f () {
2424

2525
SELF=$(readlink_f "$0")
2626
SCRIPT_PATH=$(dirname "$SELF")
27-
exec "$SCRIPT_PATH"/elixir --compile "$@"
27+
exec "$SCRIPT_PATH"/elixir +compile "$@"

bin/elixirc.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ echo ** Options marked with (*) can be given more than once
1818
echo ** Options given after -- are passed down to the executed code
1919
echo ** Options can be passed to the erlang runtime using ELIXIR_ERL_OPTS" >&2
2020
:run
21-
call "%~dp0\elixir.bat" --compile %*
21+
call "%~dp0\elixir.bat" +compile %*

bin/iex

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ readlink_f () {
3333

3434
SELF=$(readlink_f "$0")
3535
SCRIPT_PATH=$(dirname "$SELF")
36-
ELIXIR_NO_CLI=1 exec "$SCRIPT_PATH"/elixir --no-halt --erl "-user Elixir-IEx-CLI" "$@"
36+
ELIXIR_NO_CLI=1 exec "$SCRIPT_PATH"/elixir --no-halt --erl "-user Elixir-IEx-CLI" +iex "$@"

bin/iex.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@echo off
2-
call "%~dp0\elixir.bat" --no-halt -e "IEx.start" %*
2+
call "%~dp0\elixir.bat" +iex --no-halt -e "IEx.start" %*

lib/elixir/lib/kernel/cli.ex

+33-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ defmodule Kernel.CLI do
141141
process_shared t, config.update_commands [{:cookie,h}|&1]
142142
end
143143

144-
defp process_shared([erl,_|t], config) when erl in ["--erl", "--sname", "--remsh", "--name"] do
144+
defp process_shared([erl,_|t], config) when erl in ["--erl", "--sname", "--name"] do
145145
process_shared t, config
146146
end
147147

@@ -155,10 +155,14 @@ defmodule Kernel.CLI do
155155
{ config, t }
156156
end
157157

158-
defp process_argv(["--compile"|t], config) do
158+
defp process_argv(["+compile"|t], config) do
159159
process_compiler t, config
160160
end
161161

162+
defp process_argv(["+iex"|t], config) do
163+
process_iex t, config
164+
end
165+
162166
defp process_argv(["-S",h|t], config) do
163167
{ config.update_commands([{:script,h}|&1]), t }
164168
end
@@ -212,6 +216,33 @@ defmodule Kernel.CLI do
212216
{ config.update_commands([{:compile,config.compile}|&1]), [] }
213217
end
214218

219+
# Process iex options
220+
221+
defp process_iex(["--"|t], config) do
222+
{ config, t }
223+
end
224+
225+
defp process_iex([opt,_|t], config) when opt in ["--remsh"] do
226+
process_iex t, config
227+
end
228+
229+
defp process_iex(["-S",h|t], config) do
230+
{ config.update_commands([{:script,h}|&1]), t }
231+
end
232+
233+
defp process_iex([h|t] = list, config) do
234+
case h do
235+
"-" <> _ ->
236+
shared_option? list, config, process_iex(&1, &2)
237+
_ ->
238+
{ config.update_commands([{:file,h}|&1]), t }
239+
end
240+
end
241+
242+
defp process_iex([], config) do
243+
{ config, [] }
244+
end
245+
215246
# Process commands
216247

217248
defp process_command({:cookie,h}, _config) do

0 commit comments

Comments
 (0)