libs/commandio.js
function addCommand(descriptor){
	// Check descriptor type.
	var err = {};
	if( !checkDescriptor(descriptor, err) ){
		logger.error(
			'The command descriptor is invalid.',
			new Error('[command.io] Invalid command descriptor ("'+err.key+'": expected "'+err.expect+'", have "'+err.type+'").')
		);
		logger.error('Please check this doc: https://github.com/Techniv/node-command-io/wiki/Command-descriptor-refactoring');
		return module.exports;
	}

	var name = descriptor.name;
	descriptor.controller = new CommandController(descriptor);

    // Index the command descriptor
    commandDescriptors[name] = descriptor;

    // Chain addCommand
    return module.exports;
}
function addCommand(descriptor){
	// Check descriptor type.
	var err = {};
	if( !checkDescriptor(descriptor, err) ){
		logger.error(
			'The command descriptor is invalid.',
			new Error('[command.io] Invalid command descriptor ("'+err.key+'": expected "'+err.expect+'", have "'+err.type+'").')
		);
		logger.error('Please check this doc: https://github.com/Techniv/node-command-io/wiki/Command-descriptor-refactoring');
		return module.exports;
	}

	var name = descriptor.name;
	descriptor.controller = new CommandController(descriptor);

    // Index the command descriptor
    commandDescriptors[name] = descriptor;

    // Chain addCommand
    return module.exports;
}
function addCommand ( descriptor ) { // Check descriptor type. var err = { } ; if ( ! checkDescriptor ( descriptor , err ) ) { logger . error ( 'The command descriptor is invalid.' , new Error ( '[command.io] Invalid command descriptor ("' + err . key + '": expected "' + err . expect + '", have "' + err . type + '").' ) ) ; logger . error ( 'Please check this doc: https://github.com/Techniv/node-command-io/wiki/Command-descriptor-refactoring' ) ; return module . exports ; } var name = descriptor . name ; descriptor . controller = new CommandController ( descriptor ) ; // Index the command descriptor commandDescriptors [ name ] = descriptor ; // Chain addCommand return module . exports ; }
Add a command
@param name string
@param description string
@param action Function
@returns Object return Command.IO API.
Add a command