_verifyNoPromptOptions()

in generators/generator-botbuilder/generators/app/index.js [149:191]


    _verifyNoPromptOptions() {
        this.templateConfig = _.pick(this.options, ['botname', 'description', 'language', 'template', 'addtests'])

        // validate we have what we need, or we'll need to throw
        if(!this.templateConfig.botname) {
          throw new Error('Must specify a name for your bot when using --noprompt argument.  Use --botname or -N');
        }
        if(!this.templateConfig.description) {
            throw new Error('Must specify a description for your bot when using --noprompt argument.  Use --description or -D');
        }

        // make sure we have a supported language
        const language = (this.templateConfig.language ? _.toLower(this.templateConfig.language) : undefined);
        const langJS = _.toLower(BOT_LANG_NAME_JAVASCRIPT);
        const langTS = _.toLower(BOT_LANG_NAME_TYPESCRIPT);
        if(!language || (language !== langJS && language !== langTS)) {
            throw new Error('Must specify a programming language when using --noprompt argument.  Use --language or -L');
        }

        // make sure we have a supported template
        const template = (this.templateConfig.template ? _.toLower(this.templateConfig.template) : undefined);
        const tmplEmpty = _.toLower(BOT_TEMPLATE_NOPROMPT_EMPTY);
        const tmplSimple = _.toLower(BOT_TEMPLATE_NOPROMPT_SIMPLE);
        const tmplCore = _.toLower(BOT_TEMPLATE_NOPROMPT_CORE);
        if (!template || (template !== tmplEmpty && template !== tmplSimple && template !== tmplCore)) {
            throw new Error('Must specify a template when using --noprompt argument.  Use --template or -T');
        }

        // let's see if unit tests are requested
        if(this.templateConfig.addtests) {
            // so they're asking for tests, let's make sure they've specified the corebot template
            // or else we have an invalid set of command line arguments.  unit tests are only available
            // with the corebot template
            if(template !== tmplCore) {
                throw new Error('Invalid use of --addtests.  Can only be specified when using --template "core" or  -T "core" ');
            }
        } else {
            this.templateConfig.addtests = false;
        }
            // when run using --noprompt and we have all the required templateConfig, then set final confirmation to true
        // so we can go forward and create the new bot without prompting the user for confirmation
        this.templateConfig.finalConfirmation = true;
    }