Or do I have to build it and then run the executable with the arguments?
I’m pretty sure it’s just odin run . -- <args>.
1 Like
Thanks! I was pretty sure that I’ve tried your suggestion in the past and it didn’t work, but I have just now tried again and it works!
For anyone else, quick test code if you want to verify this (I’m on Windows):
package howtopassargsonrun
import "core:os"
import "core:fmt"
main :: proc() {
fmt.println(os.args)
return
}
Then do odin run . -- testarg and you should get something like this:
["D:/tmp/odin/snippet/snippet.exe", "testarg"]
For those who don’t know: The first argument you get back is always the absolute path of the executable you are running. It’s like that in C as well (at least under normal circumstances when you start the program yourself and it is not started by some other program).
1 Like