Skip to content

showHelpOnFail does not show the message when set to false #2085

@neha-sri

Description

@neha-sri

From the docs:

showHelpOnFail(enable: boolean, message?: string): Argv<T>;
By default, yargs outputs a usage string if any error is detected. Use the .showHelpOnFail() method to customize this behavior.
Params:
enable – If false, the usage string is not output.
message – Message that is output after the error message.

We are using it in the following manner:

export const builder = function (yargs: yargs.Argv): yargs.Argv {
  return yargs
    .commandDir('feedback-commands', {
      extensions: ['js'],
    })
    .strict()
    .showHelpOnFail(false, `Use ' --help' for usage`)
    .demandCommand();
};

However, the string passed in the parameter message is never displayed. Only the error message Not enough non-option arguments: got 0, need at least 1 is being displayed.

To be clear, we want to not display the help page but print a string after the error message instead.

PS: The string also doesn't get displayed when the parameter value is set true since --help output instead.

We are on version 17.0.1 but I tried with 17.0.3 as well and same result.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions