Last active
January 10, 2021 13:11
-
-
Save iksena/7ad7dbb03ae45a7e767cde43317311bd to your computer and use it in GitHub Desktop.
Microservice Main Generator for asking arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Generator = require('yeoman-generator'); | |
class MicroserviceGenerator extends Generator { | |
constructor(args, opts) { | |
super(args, opts); | |
// yo microservice Example | |
this.argument('name', { | |
type: String, | |
description: 'Microservice Name', | |
required: true, | |
default: 'Example', | |
}); | |
console.log('Name as argument', this.options.name); | |
// yo microservice --another-name=Example | |
// yo microservice -n=Example | |
this.option('anotherName', { | |
alias: 'n', | |
type: String, | |
description: 'Microservice Name', | |
default: 'Example', | |
}); | |
console.log('Name as option', this.options.anotherName); | |
} | |
async prompting() { | |
// > yo microservice | |
// ? What is the name of the microservice? (Example) | |
this.answers = await this.prompt([ | |
{ | |
name: 'name', | |
type: 'input', | |
default: 'Example', | |
message: 'What is the name of the microservice?', | |
}, | |
]); | |
console.log('Name as prompt', this.answers.name); | |
} | |
} | |
module.exports = MicroserviceGenerator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment