Skip to content
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

Help description does not match actual input #847

Open
mainrs opened this issue Feb 4, 2018 · 3 comments
Open

Help description does not match actual input #847

mainrs opened this issue Feb 4, 2018 · 3 comments

Comments

@mainrs
Copy link

mainrs commented Feb 4, 2018

I wrote a small dummy sub-generator that just prints out its arguments.
If I call it using the help flag (yo efs:action -h), I get the following output:

Usage:
  yo efs:action [options] <actionFileName> <actionCreatorName>

Options:
  -h,    --help           # Print the generator's options and usage
         --skip-cache     # Do not remember prompt answers                                              Default: false
         --skip-install   # Do not automatically install dependencies                                   Default: false
  -sc,   --skip-constant  # This will skip the creation of a constant for the specific action creator.  Default: false

Arguments:
  actionFileName       Type: String  Required: true
  actionCreatorName    Type: String  Required: true

Calling it again with yo efs:action -sc filename creatorname fails, even though it is valid as seen by the help output. Option can go before arguments. The following error is printed to the console:

Error: Did not provide required argument actionCreatorName!
    at _arguments.forEach (/Users/Sven/Desktop/generator-efs/node_modules/yeoman-generator/lib/index.js:351:35)
    at Array.forEach (<anonymous>)
    at ActionGenerator.checkRequiredArgs (/Users/Sven/Desktop/generator-efs/node_modules/yeoman-generator/lib/index.js:347:21)
    at ActionGenerator.parseOptions (/Users/Sven/Desktop/generator-efs/node_modules/yeoman-generator/lib/index.js:332:10)
    at ActionGenerator.argument (/Users/Sven/Desktop/generator-efs/node_modules/yeoman-generator/lib/index.js:255:10)
    at new ActionGenerator (/Users/Sven/Desktop/generator-efs/generators/action/index.js:22:14)
    at Environment.instantiate (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:403:12)
    at Environment.create (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:381:17)
    at Environment.run (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:438:28)
    at env.lookup (/usr/local/lib/node_modules/yo/lib/cli.js:156:11)

Another "issue" I found was that I can't use the alias defined in the options flag. It works only for --sc and not if I pass -sc (as I would have expected for a shortcut). -h works though.
Here is the generator if it is relevant:

'use strict';
const Generator = require('yeoman-generator');

class ActionGenerator extends Generator {
    constructor(args, opts) {
        super(args, opts);
        
        this.option('skip-constant', {
            alias: 'sc',
            desc: 'This will skip the creation of a constant for the specific action creator.',
            type: Boolean,
            default: false,
        });

        // this is the name of the actual action file. Files can hold more than one action.
        this.argument('actionFileName', { 
            type: String,
            required: true,
            store: true,
        });
        this.argument('actionCreatorName', { type: String, required: true });
    }

    prompting() {
        // testing
        return this.prompt([]).then(answers => {
            console.log("creating action creator " + this.options.actionCreatorName + " in file " + this.options.actionFileName + 
            ". Using constant? " + this.options["skip-constant"]);
        });
    }
}
module.exports = ActionGenerator;
@SBoudrias
Copy link
Member

Are you interested in sending a fix PR?

The relevant repository is: https://github.com/yeoman/yo

And some of those issues might be caused by https://github.com/sindresorhus/meow that we use for the CLI input parsing.

@mainrs
Copy link
Author

mainrs commented Feb 5, 2018

If I can fix it for sure. I will take a look! Thanks for linking the repo 😄

@jednano
Copy link

jednano commented Aug 2, 2019

Same problem here. Must pass --sc instead of what the help doc says, -sc.

@JoshuaKGoldberg JoshuaKGoldberg transferred this issue from yeoman/yeoman Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants