diff --git a/elm-io.sh b/elm-io.sh index 5907a58..69bee7a 100755 --- a/elm-io.sh +++ b/elm-io.sh @@ -1,14 +1,18 @@ #!/usr/bin/env bash -if [ "$#" -ne 2 ]; then - echo "Usage: $0 " +if [ "$#" = 3 ]; then + MAIN_MODULE=$3 +elif [ "$#" = 2 ]; then + MAIN_MODULE=Main +else + echo "Usage: $0 [
]" exit 1 fi read -d '' handler <<- EOF (function(){ if (typeof Elm === "undefined") { throw "elm-io config error: Elm is not defined. Make sure you call elm-io with a real Elm output file"} - if (typeof Elm.Main === "undefined" ) { throw "Elm.Main is not defined, make sure your module is named Main." }; - var worker = Elm.worker(Elm.Main); + if (typeof Elm.${MAIN_MODULE} === "undefined" ) { throw "Elm.${MAIN_MODULE} is not defined, make sure your module is named Main." }; + var worker = Elm.worker(Elm.${MAIN_MODULE}); })(); EOF