COMMUNITY

Interp target: passing arguments

This is my build.hxml:

-cp Source
-main Main
--interp

and this is the Source/Main.hx:

package;
class Main {
    public static function main() {
        trace(Sys.args());
    }
}

Running haxe build.hxml yields:

$ haxe build.hxml
Source/Main.hx:4: [-cp,Source,-main,Main,--interp]
$

And haxe build.hxml my_arg gives:

$ haxe build.hxml my_arg
(unknown) : Package "my_arg" was not found in any of class paths
$

Question is: Is it possible to pass arguments to interp target and if yes, how one goes about doing that?

Check out --run.

That’s it! Thanks Simon!

This is what I did in build.hxml:

-cp Source
-main Main
--run Main
arg1
arg2

and then:

$ haxe build.hxml
Source/Main.hx:4: [arg1,arg2]
$

Another way is to have build.hxml like so:

-cp Source
-main Main

and then run:

$ haxe build.hxml --run Main arg1 arg2
Source/Main.hx:4: [arg1,arg2]
$

Note that you don’t need -main with --run.

this should probably error as “multiple target” or something