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

Command-line arguments for all options #13

Open
simenlf opened this issue Jul 28, 2021 · 3 comments
Open

Command-line arguments for all options #13

simenlf opened this issue Jul 28, 2021 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@simenlf
Copy link

simenlf commented Jul 28, 2021

Love the application. Well done!
Is it possible for you to add command-line arguments for all options in the generator, so that I can run it without user interaction at all? This works for some, but all the options i think?

Thank you

@IObert
Copy link
Contributor

IObert commented Jul 30, 2021

Hi,

this is a cool idea. Currently it's not possible but I'll leave that idea open in case someone wants to implement this.

@IObert IObert added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jul 30, 2021
@lboehm
Copy link
Contributor

lboehm commented Dec 19, 2021

Hi @IObert,

I've created a possible solution for this issue. You can view the changes here.
I didn't create a PR, because it's not finished yet. I wanted to discuss my approach first, before finishing it.

What I did

You can now call the generator with command line args for every option, for example like this:

-n appName -s myns -p \"Static webserver\" -v XML -l \"Content delivery network (SAPUI5)\" -d true -c true

As every option is provided the generator will run without prompting anything. If an option is missing yeoman will show a prompt for the missing option(s).

Further improvements

  1. Right now the input that is provided via cmd args is not validated. Input provided by the user is validated through the validate function of the yeoman prompt. I would like to create a js file (something like inputValidation.js, which provides validate functions. Those functions could then be called to validate cmd args and yeoman input.

  2. Right now you have to provide the exact value for every parameter, e.g. "SAP Launchpad service" for the platform parameter or "Content delivery network (SAPUI5)" for ui5libs parameter. This isn't easy to use, especially because you have to escape spaces. I would like to add a mapping so that the user can provide a technical key for a parameter, which is then mapped to the value the generator is expecting.
    To do so, I think code quality would improve if we would use constants for the various strings (e.g. SAP HTML5 Application Repository service for SAP BTP).

Please have a look at my implementation and the further improvements I suggest and let me know if I should proceed.

Thanks and best regards
Lukas

@IObert
Copy link
Contributor

IObert commented Dec 20, 2021

Thanks for your PR!
I'd suggest a minor change to adress the improvement 1) you mentioned. You could kill two birds with one stone if you change the when condition (e.g. when: !options.newdir ) to run the validation of the option and only return true if the validation passes.

Also, I have one more question about the original issue. @simenlf Did you want to call generator-ui5-project with options or easy-ui5 with options? Because if you're talking about the latter, this would require changes in easy-ui5 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants