A simple, easy to use command line flag parser for Odin.
Installation User Guide Contributing
package main
import "core:fmt"
import flag "../.." // path to package
main :: proc() {
using flag
flags := flagset()
count := 1
send := false
msg: string
flags->add("count", &count, int)
flags->add("send", &send, bool)
flags->add("msg", &msg, string)
flags->parse()
if send {
for _ in 0..<count {
fmt.println(msg)
}
}
flags->free()
}
✨ For more examples see the User Guide ✨
The recommended way to install odin-flag is to use git submodules.
In your project, create a directory called "external" (or alternative name) and run the command below.
git submodule add https://github.com/hrszpuk/odin-flag external/odin-flag
From your project directory you can access the library like in the code below.
package main
import flag "external/odin-flag"
main :: proc() {
using flag
flag := flagset()
// ...
flag->free()
}
NOTE: the path to odin-flag may be different depending on where odin-flag is installed and where you are trying to access odin-flag from. Your first step to troubleshoot installation issues is to check where odin-flag is installed and where you are trying to access odin-flag from.
If you wish to contribute new features, report/fix a bug, or discuss changes/additions to the product please create an issue.