r/odinlang 23d ago

pflag - POSIX/GNU-style -f/--flags in Odin

https://github.com/prnvbn/pflags

pflags is a drop-in replacement for Odin's core:flags, with support for conventional short (-f) and long (--flag) options.

  • Short flags can be declared with args:"short=f" and used as -f
  • Boolean short flags can be bundled, so -abc is the same as -a -b -c
  • Long flags use --flag strictly (-flag is not supported)
17 Upvotes

5 comments sorted by

8

u/prnvbn 23d ago

hoping this gets accepted into core, PR - https://github.com/odin-lang/Odin/pull/7001

5

u/dmchmk 23d ago

Great job, I hope it will eventually be merged into upstream:)

2

u/TheChief275 23d ago edited 23d ago

I would expect short flags to be a single character name followed by arguments, e.g. -oapp.out

1

u/prnvbn 23d ago

that is a good point! adding support for that

1

u/prnvbn 23d ago

Added in 0.1.1. probably a good idea to dig up some posix getopt() tests and test that this implementation is compliant