I like the flags package for many reasons, especially the flags.parse procedure.
I’m not fond of the flags.write_usage procedure, in that the printed format is not modifiable and for my taste uses too much white space and extra characters. I’d prefer if there was a procedure that returns a structure that contains all the validated data without the extra formatting. One that does all the same things write_usage does (sort, validate, determine required, min, max, range, types, usage description, flag names, etc), but does not print. This way I could create my own uniform usage printing format from an expected structure that could be reusable across projects.
As a side note, if this is considered as a request, I’d like it if the sort had options like: ([sort only position], [sort position and required], [sort position and required and alphanumeric], etc), where the ignored category of sort-ables are left in their relative position.
Something like [ ]Arg_Tag where the len(Arg_Tag) is the number of fields in the Args :: struct.
Arg_Tag :: struct {
style: enum, //.Odin or .Unix
name: string, // from subtag args:"name=some_name" || field name
stype: string, // string derived from nested type info and named types, (?indistinct?) etc.
rtype: ^runtime.Type_Info // for validation procs ??
usage: string, // from subtags || empty
file: string, // from subtags || default || empty if type is not a file
perms: string, // from subtags || default || empty if type is not a file
min: int, // from subtags || -1 and/or determined by combinations of range, etc
max: int, // from subtags || -1 and/or determined by combinations of range, etc
pos: int, // from subtags || -1
manifold: int, // from subtags || -1 -> .Unix only
hidden: bool, // from subtags true if present
required: bool, // from subtags true if present
overflow: bool, // from subtags true if present
}
This could have the added benefit that both the flags.parse and flags.write_usage (and other procedures) in flag:core could validate from the same structure without either having to reinvent the wheel on their own, as it appears.