Skip to content

Instantly share code, notes, and snippets.

@iksena
Last active January 10, 2021 13:11
Show Gist options
  • Save iksena/7ad7dbb03ae45a7e767cde43317311bd to your computer and use it in GitHub Desktop.
Save iksena/7ad7dbb03ae45a7e767cde43317311bd to your computer and use it in GitHub Desktop.
Microservice Main Generator for asking arguments
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