-
Notifications
You must be signed in to change notification settings - Fork 2
Sflags
maxlandon edited this page Jan 8, 2023
·
3 revisions
This page is intended for users of octago/sflags.
The flags library is actually almost forked from sflags, and the entire code for generating command flags (not positional arguments for now) is exactly the same (with some fixes). Users should thus expect mostly the same behavior.
However, there are a few differences, listed below:
- The
flags.OptFuncsnow include a newflags.ParseAll(), to indicate to the generator that the struct fields, regardless of them being tagged or not, have to be parsed into cobra command flags. This is because by default, the flags library will ignore all struct fields that are not tagged either as commands, positionals, flags or groups of them. - The
validator/govalidatorpackage is still provided and compatible with this library. I added thevalidatorcode usinggithub.com/go-playground/validatorbecause the former is not maintained anymore, and most of its peculiar features are not needed. Additionally,go-validatoralso enables to pass custom validations, error messages, and also has a long list of builtin validations.-
github.com/reeflective/flags/validator/govalidatoris the legacy one. -
github.com/reeflective/flags/validatoris the new one.
-