0.1.0 • Published 9 years ago

microscope-cli v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
9 years ago

microscope-cli

microscopejs command line interface librairies.

Application

Class for Command Line Interface console application.

Usage sample:

required properties:

  • templatesRoot
  • controllersRoot
// Imports
var Application = require('microscope-cli').Application;

// ConsoleApplication class.
module.exports = Application.extend({

	templatesRoot: __dirname + '/templates',
	controllersRoot: __dirname + '/controllers',

	options: [
		{flags: '-S, --shiv', description: 'add html5 shiv'}
	],

	initialize: function () {
		this.run();
	}
});

CliController

Cli Controller class. parse command line arguments

Usage sample:

required properties:

  • commands command (required) -- command to parse action (required) -- controller method to callback * description (optional) -- command description
// Imports
var CliController = require('microscope-cli').CliController;
var ProjectForm   = require('../forms/ProjectForm');

// HomeCliController class
module.exports = CliController.extend({

	commands: [
		{command: 'new_project <projectName>', action: 'new', description: 'create project'},
		{command: 'new', action: 'create', description: 'display project form'}
	],

	new: function (projectName) {
		if(this.kernel.getOption('shiv')) {
			this.print('Adding html5 shiv librairy', 'danger');
		}
		this.print('create new project: ' + projectName, 'danger');
	},

	create: function () {
		new ProjectForm({kernel: this.kernel});
	}
});

Form

Console form with model and rich inputs (list, password, ...)

Usage sample:

required properties:

  • model
  • response (function)
// Imports
var Form = require('microscope-cli').Form;

// ProjectForm class
module.exports = Form.extend({

	model: [{
		type: "input",
		name: "projectName",
		message: "What is your project name ?"
	}],

	initialize: function () {
		this.render();
	},

	response: function (answers) {
		this.print(answers.projectName, 'danger');
	}
});