scripts/generator.js
function startCmdEditor (config, is_skip_header) {

	if (!is_skip_header) {
		console.log(colors.bold('--------------- Command Editor ---------------'));
	}

	// Show a prompt for choose the mode
	var promise = inquirer.prompt([{
		type: 'list',
		name: 'mode',
		message: 'What you want to do ?',
		choices: [
			'Show commands list', 'Add new command', 'Edit command', 'Delete command'
		]
	}]);

	promise.then(function (answer) {

		var mode = answer.mode;
		var promise = null;

		if (mode == 'Add new command') {
			promise = addCommandOnCmdEditor(config);
		} else if (mode == 'Edit command') {
			promise = editCommandOnCmdEditor(config);
		} else if (mode == 'Delete command') {
			promise = deleteCommandOnCmdEditor(config);
		} else if (mode == 'Show commands list') {
			promise = showCommandsOnCmdEditor(config);
		}

		if (!promise) {
			startCmdEditor(config, true);
			return;
		}

		promise.then(function () {
			startCmdEditor(config, true);
		});

	});

}
function startCmdEditor (config, is_skip_header) {

	if (!is_skip_header) {
		console.log(colors.bold('--------------- Command Editor ---------------'));
	}

	// Show a prompt for choose the mode
	var promise = inquirer.prompt([{
		type: 'list',
		name: 'mode',
		message: 'What you want to do ?',
		choices: [
			'Show commands list', 'Add new command', 'Edit command', 'Delete command'
		]
	}]);

	promise.then(function (answer) {

		var mode = answer.mode;
		var promise = null;

		if (mode == 'Add new command') {
			promise = addCommandOnCmdEditor(config);
		} else if (mode == 'Edit command') {
			promise = editCommandOnCmdEditor(config);
		} else if (mode == 'Delete command') {
			promise = deleteCommandOnCmdEditor(config);
		} else if (mode == 'Show commands list') {
			promise = showCommandsOnCmdEditor(config);
		}

		if (!promise) {
			startCmdEditor(config, true);
			return;
		}

		promise.then(function () {
			startCmdEditor(config, true);
		});

	});

}
function startCmdEditor ( config , is_skip_header ) { if ( ! is_skip_header ) { console . log ( colors . bold ( '--------------- Command Editor ---------------' ) ) ; } // Show a prompt for choose the mode var promise = inquirer . prompt ( [ { type : 'list' , name : 'mode' , message : 'What you want to do ?' , choices : [ 'Show commands list' , 'Add new command' , 'Edit command' , 'Delete command' ] } ] ) ; promise . then ( function ( answer ) { var mode = answer . mode ; var promise = null ; if ( mode == 'Add new command' ) { promise = addCommandOnCmdEditor ( config ) ; } else if ( mode == 'Edit command' ) { promise = editCommandOnCmdEditor ( config ) ; } else if ( mode == 'Delete command' ) { promise = deleteCommandOnCmdEditor ( config ) ; } else if ( mode == 'Show commands list' ) { promise = showCommandsOnCmdEditor ( config ) ; } if ( ! promise ) { startCmdEditor ( config , true ) ; return ; } promise . then ( function ( ) { startCmdEditor ( config , true ) ; } ) ; } ) ; }
Start the command editor
@param  {Object} config             Current configuration
@param  {Boolean} is_skip_header    Whether the header should be skipped
Start the command editor