diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-06-06 18:35:43 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-06-07 13:16:13 -0400 |
| commit | edb685f04be9aef407dc8abac7bb76fb51184f9f (patch) | |
| tree | 63f48c951de7a9d751895a3cd72194e241bd38c0 /core/flags/validation.odin | |
| parent | 08612423b9afffb7499d8db2c69715df1627bd50 (diff) | |
Add package `core:flags`
Diffstat (limited to 'core/flags/validation.odin')
| -rw-r--r-- | core/flags/validation.odin | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/core/flags/validation.odin b/core/flags/validation.odin new file mode 100644 index 000000000..e370cff48 --- /dev/null +++ b/core/flags/validation.odin @@ -0,0 +1,37 @@ +package flags + +/* +Check a flag after parsing, during the validation stage. + +Inputs: +- model: A raw pointer to the data structure provided to `parse`. +- name: The name of the flag being checked. +- value: An `any` type that contains the value to be checked. +- args_tag: The `args` tag from within the struct. + +Returns: +- error: An error message, or an empty string if no error occurred. +*/ +Custom_Flag_Checker :: #type proc( + model: rawptr, + name: string, + value: any, + args_tag: string, +) -> ( + error: string, +) + +@(private) +global_custom_flag_checker: Custom_Flag_Checker + +/* +Set the global custom flag checker. + +Note that only one can be active at a time. + +Inputs: +- checker: The flag checker. Pass `nil` to disable any previously set checker. +*/ +register_flag_checker :: proc(checker: Custom_Flag_Checker) { + global_custom_flag_checker = checker +} |