You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was going through ESLint configuration for optionator and wanted to enhance validation a bit, and ran into a few limitations:
Exclusive options
Currently it's possible to setup mutuallyExclusive options, however, it's really tough to mark a given option as fully exclusive (as in, doesn't work with any other option). In ESLint configuration, such options would be --init and --help.
It would also be nice to mark an option exclusive for anything other then _ input. An example of such option in ESLint would be --print-config [file].
DependsOn with a value
Currently dependsOn can only specify the name of the option that is required to have any value. I would like to be able to require a specific value. For example, --ignore option in ESLint has a default of true, and --ignore-file only makes sense when it is true, but if --ignore is set to false, --ignore-file doesn't make any sense any more. Currently it's not possible to set this up.
Ability to dependOn _ option
A lot of options in ESLint only make sense if the user provided a file or a glob. As far as I can tell, there's no way to depend on that right now.
Ability to specify error message for validation error
I would like to mark some options mutuallyExclusive, but provide a better error message when two or more of those options are used. I understand that current array of array format doesn't leave much space for custom error messages, so maybe another format can be introduced side-by-side? Or as a last resort, when optionator.parse throws, could error object include all of the options that were used with their values? That would at least allow to intercept errors and specify a better message. Would be nice to be able to specify custom error message for dependsOn as well. Currently it only says that requirements were not met, without explaining those requirements at all.
The text was updated successfully, but these errors were encountered:
It would also be helpful to have sort of the opposite of dependsOn _, so that a named argument could be mutually exclusive with a positional argument (or with all positional arguments). An example use case would be specifying a --path to a directory vs. a list of files.
I was going through ESLint configuration for optionator and wanted to enhance validation a bit, and ran into a few limitations:
Exclusive options
Currently it's possible to setup
mutuallyExclusive
options, however, it's really tough to mark a given option as fully exclusive (as in, doesn't work with any other option). In ESLint configuration, such options would be--init
and--help
.It would also be nice to mark an option exclusive for anything other then
_
input. An example of such option in ESLint would be--print-config [file]
.DependsOn with a value
Currently
dependsOn
can only specify the name of the option that is required to have any value. I would like to be able to require a specific value. For example,--ignore
option in ESLint has a default oftrue
, and--ignore-file
only makes sense when it istrue
, but if--ignore
is set tofalse
,--ignore-file
doesn't make any sense any more. Currently it's not possible to set this up.Ability to dependOn
_
optionA lot of options in ESLint only make sense if the user provided a file or a glob. As far as I can tell, there's no way to depend on that right now.
Ability to specify error message for validation error
I would like to mark some options
mutuallyExclusive
, but provide a better error message when two or more of those options are used. I understand that current array of array format doesn't leave much space for custom error messages, so maybe another format can be introduced side-by-side? Or as a last resort, whenoptionator.parse
throws, could error object include all of the options that were used with their values? That would at least allow to intercept errors and specify a better message. Would be nice to be able to specify custom error message fordependsOn
as well. Currently it only says that requirements were not met, without explaining those requirements at all.The text was updated successfully, but these errors were encountered: