scripts/generator.js
function addCommandOnCmdEditor (config) {

	var cmd_name = null;

	var promise = inquirer.prompt([{
		type: 'input',
		name: 'cmdName',
		message: 'What is name of a command (e.g. setMotorPower) ?',
		validate: function (value) {
			if (value.length == 0) return true;
			if (config.commands[value] != null) return 'This command name has already existed.';
			if (!value.match(/^[A-Za-z0-9_]+$/)) return 'Available characters for argument name: A-Z, a-z, 0-9, underscore.\n\
Or, if you want to cancel, please press the enter key left empty.';
			return true;
		}

	}]).then(function (answer) {

		cmd_name = answer.cmdName || null;
		if (cmd_name == null || cmd_name.length == 0) {
			return null;
		}

		return inquirer.prompt([{
			type: 'input',
			name: 'cmdDesc',
			message: 'What is description of ' + cmd_name + ' command ?'
		}]);


	}).then(function (answer) {

		if (cmd_name == null) return false;

		var commands = config.commands || {};
		commands[cmd_name] = {
			description: answer.cmdDesc || null,
			args: {}
		};

		// Done
		console.log(colors.bold.green('This command has been created: ' + cmd_name));

		// Save to the commands file
		console.log('\nWriting to ' + process.cwd() + '/' + COMMANDS_FILENAME);
		fs.writeFileSync(COMMANDS_FILENAME, JSON.stringify(config.commands));
		console.log('Writing has been completed.\n\n');
		return true;

	});

	return promise;

}
function addCommandOnCmdEditor (config) {

	var cmd_name = null;

	var promise = inquirer.prompt([{
		type: 'input',
		name: 'cmdName',
		message: 'What is name of a command (e.g. setMotorPower) ?',
		validate: function (value) {
			if (value.length == 0) return true;
			if (config.commands[value] != null) return 'This command name has already existed.';
			if (!value.match(/^[A-Za-z0-9_]+$/)) return 'Available characters for argument name: A-Z, a-z, 0-9, underscore.\n\
Or, if you want to cancel, please press the enter key left empty.';
			return true;
		}

	}]).then(function (answer) {

		cmd_name = answer.cmdName || null;
		if (cmd_name == null || cmd_name.length == 0) {
			return null;
		}

		return inquirer.prompt([{
			type: 'input',
			name: 'cmdDesc',
			message: 'What is description of ' + cmd_name + ' command ?'
		}]);


	}).then(function (answer) {

		if (cmd_name == null) return false;

		var commands = config.commands || {};
		commands[cmd_name] = {
			description: answer.cmdDesc || null,
			args: {}
		};

		// Done
		console.log(colors.bold.green('This command has been created: ' + cmd_name));

		// Save to the commands file
		console.log('\nWriting to ' + process.cwd() + '/' + COMMANDS_FILENAME);
		fs.writeFileSync(COMMANDS_FILENAME, JSON.stringify(config.commands));
		console.log('Writing has been completed.\n\n');
		return true;

	});

	return promise;

}
function addCommandOnCmdEditor ( config ) { var cmd_name = null ; var promise = inquirer . prompt ( [ { type : 'input' , name : 'cmdName' , message : 'What is name of a command (e.g. setMotorPower) ?' , validate : function ( value ) { if ( value . length == 0 ) return true ; if ( config . commands [ value ] != null ) return 'This command name has already existed.' ; if ( ! value . match ( / ^[A-Za-z0-9_]+$ / ) ) return 'Available characters for argument name: A-Z, a-z, 0-9, underscore.\n\
Or, if you want to cancel, please press the enter key left empty.' ; return true ; } } ] ) . then ( function ( answer ) { cmd_name = answer . cmdName || null ; if ( cmd_name == null || cmd_name . length == 0 ) { return null ; } return inquirer . prompt ( [ { type : 'input' , name : 'cmdDesc' , message : 'What is description of ' + cmd_name + ' command ?' } ] ) ; } ) . then ( function ( answer ) { if ( cmd_name == null ) return false ; var commands = config . commands || { } ; commands [ cmd_name ] = { description : answer . cmdDesc || null , args : { } } ; // Done console . log ( colors . bold . green ( 'This command has been created: ' + cmd_name ) ) ; // Save to the commands file console . log ( '\nWriting to ' + process . cwd ( ) + '/' + COMMANDS_FILENAME ) ; fs . writeFileSync ( COMMANDS_FILENAME , JSON . stringify ( config . commands ) ) ; console . log ( 'Writing has been completed.\n\n' ) ; return true ; } ) ; return promise ; }
Command Editor - Add a command
@param  {Object} config             Current configuration
@return {Promise}
Command Editor - Add a command