@@ -6,7 +6,7 @@ defmodule ElixirScript.CLI do
66 @ switches [
77 output: :binary , elixir: :boolean ,
88 help: :boolean , core_path: :binary ,
9- full_build: :boolean , version: :boolean ,
9+ full_build: :boolean , version: :boolean ,
1010 watch: :boolean
1111 ]
1212
@@ -21,13 +21,19 @@ defmodule ElixirScript.CLI do
2121 end
2222
2323 def parse_args ( args ) do
24- parse = OptionParser . parse ( args , switches: @ switches , aliases: @ aliases )
25-
26- case parse do
27- { [ help: true ] , _ , _ } -> :help
28- { [ version: true ] , _ , _ } -> :version
29- { options , [ input ] , _ } -> { input , options }
30- _ -> :help
24+ { options , input , errors } = OptionParser . parse ( args , switches: @ switches , aliases: @ aliases )
25+
26+ cond do
27+ length ( errors ) > 0 ->
28+ :help
29+ Keyword . get ( options , :help , false ) ->
30+ :help
31+ Keyword . get ( options , :version , false ) ->
32+ :version
33+ length ( input ) == 0 ->
34+ :help
35+ true ->
36+ { input , options }
3137 end
3238
3339 end
@@ -80,8 +86,9 @@ defmodule ElixirScript.CLI do
8086 ElixirScript . compile ( input , compile_opts )
8187 _ ->
8288 input = input
83- |> String . split ( [ " " , "," ] , trim: true )
84-
89+ |> Enum . map ( fn ( x ) -> String . split ( x , [ " " , "," ] , trim: true ) end )
90+ |> List . flatten
91+
8592 ElixirScript . compile_path ( input , compile_opts )
8693
8794 if watch do
0 commit comments