Which statement describes how to define a custom CLI flag for your generator?

Study for the Yeoman (YN) Test. Enhance your knowledge with multiple-choice questions, hints, and explanations. Prepare effectively for your exam!

Multiple Choice

Which statement describes how to define a custom CLI flag for your generator?

Explanation:
In a Yeoman generator, you define a custom CLI flag by using this.option in the generator’s constructor. This registers the flag with the CLI parser so users can pass it on the command line (for example, --name=value or --flag), and you can read the chosen value later from this.options.name. You can also specify the flag’s type, a default, and a description, such as this.option('dest', { type: String, desc: 'Destination folder', default: 'dist' }); Then you would use this.options.dest in your code to influence behavior. Other names like defineFlag, setFlag, or addFlag aren’t the standard API for declaring CLI options in Yeoman, while positional arguments would be defined with this.argument.

In a Yeoman generator, you define a custom CLI flag by using this.option in the generator’s constructor. This registers the flag with the CLI parser so users can pass it on the command line (for example, --name=value or --flag), and you can read the chosen value later from this.options.name. You can also specify the flag’s type, a default, and a description, such as this.option('dest', { type: String, desc: 'Destination folder', default: 'dist' }); Then you would use this.options.dest in your code to influence behavior. Other names like defineFlag, setFlag, or addFlag aren’t the standard API for declaring CLI options in Yeoman, while positional arguments would be defined with this.argument.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy