-
Notifications
You must be signed in to change notification settings - Fork 995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: track which arguments have been defaulted #1334
Comments
that's not exactly what i'm after. if i have and the command line there doesn't seem to be a way to tell if --abc was specified, nor if --def is using the default value, because yargs.abc will === 5 and yargs.def will be false in this cmd invocation (ie: the presence of a default causes that to be instantiated, rather than it being undefined as if it didn't appear on the command line). what's needed is some boolean on each argument to tell if it was actually present on the command line or if the default created the field in the yargs object. |
@charlesspitzer out of curiosity, what's your use-case for knowing whether or not the value was defaulted? You can get the list of defaulted values from the yargs object itself, and at least know whether the value is the same as the default. |
i have a command line which needs to enforce: if --arg1 is given, then either --arg2 OR --arg3 is required. if --arg1 has a default, it is instantiated, but there seems to be no way to see, when checking when --arg2 or --arg3 is given, whether --arg1 was instantiated via the default option or whether it was present on the command line. those 2 cases can mean different things in certain cases. |
@charlesspitzer mind taking a look at #1472, and letting me know if this would do the trick for you? |
@bcoe yes, that pr would be ok to me too. |
@giacomocerquone unfortunately I've had next to no time for open-source these days, but I'll make an effort to address @coreyfarrell's concerns on that PR "soon". |
@bcoe absolutely, take your time, no worries here, we're all grateful for the work and the effort you put in this project :) |
Say I have the arguments --abc N. If I make the default for abc be 5, then yargs will create the .abc value with 5. However, this doesn't tell me if --abc was actually seen on the command line. Is there a way to see an argument was given at all?
The text was updated successfully, but these errors were encountered: