-
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
[Question] How do I mark a command as deprecated? #2115
Comments
I believe #1559 only applies to options, whereas #1624 is for commands. ExampleYou can use My example uses the const yargs = require("yargs");
let input
/*
input = '--help' // you will see `[deprecated]` next to the command "cmd1"
input = 'cmd1 --help' // you will see `[deprecated]` next to the option "deprecated-arg"
*/
yargs(input)
.command({
command: 'cmd1',
desc: 'cmd1 desc',
builder: yargs => yargs
.option('arg', {
type: 'string',
desc: 'arg desc',
})
.option('deprecated-arg', {
type: 'string',
desc: 'deprecated-arg desc',
deprecated: true // deprecate option
// deprecated: 'use "arg" option instead' // deprecate option (with explanation)
}),
handler: argv => {
console.log(argv)
},
deprecated: true // deprecate command
// deprecated: 'use "cmd2" command instead' // deprecate command (with explanation)
})
.command({
command: 'cmd2',
desc: 'cmd2 desc',
builder: yargs => yargs
.option('arg', {
type: 'string',
desc: 'arg desc',
}),
handler: argv => {
console.log(argv)
},
})
.strict()
.parse() Does this answer your question? |
Yes, I do see the |
@ryandberger My personal opinion is that it would also be nice if a warning was emitted during validation for any deprecated commands/options used. Maybe that solution is too heavy-handed, but I think there are a few ways to make it reasonable:
I'll think on this and figure out a reasonable solution. |
Would love to see a warning emitted when the command is used. I think that would be particularly useful for automation processes. For your approach, I personally would lean towards option 2 since I imagine developers would want consistent behavior across their app. I think it would also make option 3 more natural to implement when the time comes. Appreciate your help on this! |
Related to this: I noticed that |
@shadowspawn do you know if this was ever decided on further? I'd love to have this, even if its something opt-in like with "yargs().showDeprecationMessages()" or similar. |
I see from #1559 that it is now possible to mark options as deprecated. I have attempted to use this functionality at a higher level to mark an entire command as deprecated, but it does not work. Is this feature not yet implemented or am I missing something?
This is the usage I am attempting:
The text was updated successfully, but these errors were encountered: