Open eayus opened 3 weeks ago
I've been thinking about this a bit and I feel like any robust solution will basically implement 90% of a generic command line arguments parser. I'm not sure how we feel about pulling in external libraries for the compiler (which might rely on getting the compiler packaged with a package manger like pack
). To my knowledge there are two CLI libraries, collie and sap (my own library, so I'm probably biased).
The other thing I was going to suggest is that the CLI for Idris could be broken down into subcommands, something like:
idris2 check ...
idris2 repl ...
idris2 compile ...
The main advantage for this is that we can segregate flags into the different subcommands depending on where they are relevant. For example, a user checking a file does not need to know about the flags to set the compiler backend. This would simplify the help dialogues, and (in my opinion) provide a more intuitive interface. I'm not sure whether this is something that other people agree on? It would obviously break backwards compatibility for scripts using the interface.
There is at least https://github.com/idris-community/idris2-getopts, which is a pulled-out version from contrib
(https://github.com/idris-lang/Idris2/blob/main/libs/contrib/System/Console/GetOpt.idr)
Currently, the typing the following (mistyped) command:
Will launch the repl saying it can't find the file
--chec
.This is pretty unusual behaviour, as most applications will error saying that
--chec
is not a valid flag. From a user perspective I would say its undesirable as they most likely made a typo and didn't want to start the REPL anyway. (I think there is another argument to be made that the REPL should not start if given non existent files in general).