Allow passing multiple files to elixir/iex #203

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Member

alco commented Mar 29, 2012

Previously, the following invocation

iex file1.exs file2.exs

would require file1.ex and pass file2.ex as an argument to the shell. In
order to require both files, we had to write

iex -r file1.exs file2.exs
# or
iex -r file1.exs -r file2.exs

This commit make it possible to invoke elixir in the following ways:

# both file1.exs and file2.exs are `require`d
iex file1.exs file2.exs

# files starting with '-' can still be required using '-r'
iex -r '-strange_name.exs' normal_name.exs

# to pass additional options to the shell, '--' must be used
# in this case, all .ex files are `require`d and the string
# 'this is passed to the shell' is passed as a single argument
iex file1.ex file2.ex fileN.ex -- 'this is passed to the shell'
@alco alco Allow passing multiple files to elixir/iex
Previously, the following invocation

  iex file1.exs file2.exs

would require file1.ex and pass file2.ex as an argument to the shell. In
order to require both files, we had to write

  iex -r file1.exs file2.exs
  # or
  iex -r file1.exs -r file2.exs

This commit make it possible to invoke elixir in the following ways:

  # both file1.exs and file2.exs are `require`d
  iex file1.exs file2.exs

  # files starting with '-' can still be required using '-r'
  iex -r '-strange_name.exs' normal_name.exs

  # to pass additional options to the shell, '--' must be used
  # in this case, all .ex files are `require`d and the string
  # 'this is passed to the shell' is passed as a single argument
  iex file1.ex file2.ex fileN.ex -- 'this is passed to the shell'
ade69ff
Owner

josevalim commented Mar 29, 2012

Thanks for the patch. However we need to change that just for the iex executable then. We cannot change for Elixir, because I want this to work:

elixir some_file.exs -o sample

And -o sample would be passed to some_file.exs, without a need for --.

josevalim closed this in 92b29ac Mar 29, 2012

Member

alco commented Mar 29, 2012

I might have misinterpreted your goals for elixirc, elixir and iex.

As I see it now, you want to write modules and compile them with elixirc.

When you want to test the modules, you create an .exs file that doesn't have module definitions, only executable code. You then invoke

elixir script_file.exs -someopt somearg

passing it whatever options to study the output.

Alternatively, you may want to run

iex script_file.exs -opt xyz whatever

to execute the code in it and continue running the shell to experiment with modules compiled earlier.

Did I get it right this time?

Owner

josevalim commented Mar 29, 2012

Yes, this is perfect. :) In ruby it is very common for you to create scripts and invoke them passing command line args:

ruby script_to_benchmark_website 10

Where 10 could be the number of concurrent processes. I want this same syntax for elixir. If you think we should update the guide to be explicit about these, please do send a pull request! Thanks! ❤️

@alco alco pushed a commit to alco/elixir that referenced this pull request Apr 5, 2012

@josevalim josevalim Revert "Allow many files to be passed to iex, closes #203"
This reverts commit 92b29ac.

Conflicts:

	bin/elixir
	bin/iex
ac41f5e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment