Can command descriptions be customised based on mode of use?
Author: gitgrimboCreated Jan 1, 2019Updated Aug 2, 2026
I would like to be able to display a simple 'one-liner' for the command descriptions when the top level CLI is executed, but display a more detailed description when I run a command.
For example:
>mycli
mycli [command]
Commands:
mycli command1 One line description
mycli command2 One line description
mycli command3 One line description
Options:
--version
--help>mycli command1
mycli command1
Multi...
line...
description...
Options:
--version
--helpMaybe something like (shown as a command module):
const command = "command1";
const desc = "One line description";
const builder = function(yargs) {
return yargs
.OVERRIDE_COMMAND_DESCRIPTION("multiline description ...");
};
const handler = ...;
module.exports = {
command,
desc,
builder,
handler,
};Source: yargs/yargs