ianmackenzie / elm-script

Experimental command-line scripting for Elm
34 stars 4 forks source link

Add Script.Environment.elmHome #22

Open MartinSStewart opened 4 years ago

MartinSStewart commented 4 years ago

I think the following would be a useful helper function to have once https://github.com/ianmackenzie/elm-script/issues/21 is solved.

elmHome : Script.Init -> String
elmHome init =
    let
        default =
            case init.platform of
                Script.Platform.Posix _ ->
                    "~/.elm/"

                Script.Platform.Windows ->
                    "%appdata%/elm/"
    in
    Script.Environment.get "ELM_HOME" init.environment |> Maybe.withDefault default

That said, I'm not sure if it's expected for filepaths to have a trailing / or not. It might be better if there was a Path datastructure exposed that would let you safely create and combine paths without risking getting something like "~/.elm/" ++ "/test" == "~/.elm//test"

ianmackenzie commented 4 years ago

I think the functionality could certainly be useful, but I have a few comments/questions:

Thoughts?

MartinSStewart commented 4 years ago

My use case is collecting packages licenses used in a project at work.