niti: add `-` to read the standard input
authorJean Privat <jean@pryen.org>
Fri, 3 Jun 2016 02:02:17 +0000 (22:02 -0400)
committerJean Privat <jean@pryen.org>
Fri, 3 Jun 2016 02:02:17 +0000 (22:02 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/nit.nit

index 9410b4d..a28bb6f 100644 (file)
@@ -64,6 +64,12 @@ if opt_eval.value then
        modelbuilder.load_rt_module(parent, amodule, "-")
 
        mmodules = [amodule.mmodule.as(not null)]
+else if progname == "-" then
+       var content = stdin.read_all
+       var amodule = toolcontext.parse_module(content)
+       toolcontext.check_errors
+       modelbuilder.load_rt_module(null, amodule, "-")
+       mmodules = [amodule.mmodule.as(not null)]
 else
        mmodules = modelbuilder.parse([progname])
 end