Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Create nice looking shell applications in minutes with Connect/Express inspired API and functionnalities.
var spawn = require('child_process').spawn,
shell = require('shell'),
app = new shell.Shell();
app.configure(function(){
app.use(shell.history({shell: app}));
app.use(shell.completer({shell: app}));
app.use(shell.router({shell: app}));
app.use(shell.help({shell: app, introduction: true}));
app.use(shell.error({shell: app}));
});
app.on('exit', function(){
if(app.server){ app.server.kill(); }
if(app.client){ app.client.quit(); }
});
app.cmd('start', 'Start the redis server', function(req, res, next){
app.server = spawn('redis-server', [__dirname+'/redis.conf']);
res.prompt();
});
app.cmd('keys :pattern', 'Find keys', function(req, res, next){
if(!app.client){
app.client = require('redis').createClient();
}
app.client.keys(req.params.pattern, function(err, keys){
if(err){ return res.styles.red(err.message), next(); }
res.cyan(keys.join('\n')||'no keys');
res.prompt();
});
});
`npm install shell`
var app = new shell.Shell();
app.configure(function() {
app.use(shell.history({shell: app}));
app.use(shell.completer({shell: app}));
app.use(shell.help({shell: app, introduction: true}));
});
app.configure('prod', function() {
app.set('title', 'Production Mode');
});
The constructor shell.Shell
take an optional object. options are
Like with Express, app.configure
allows the customization of plugins for all or specific environments while app.use
register plugins.
If app.configure
is called without specifying the environment as the first argument, the provided callback will always be called. Otherwise, the environment must match the global variable NODE_ENV
or the env
setting.
Shell settings may be set by calling app.set('key', value)
and may be retrieved by calling the same function without a second argument.
var app = new shell.Shell();
app.set('env', 'prod');
app.configure('prod', function() {
console.log(app.set('env'));
});
NODE_ENV
if defined.A route is made of a command pattern, an optional description and one or more route specific middleware.
Middlewares recieve three parameters, a request object, a response object and a function.
The request object contains the following properties:
The response object inherit from styles which contains various utility functions for printing, coloring and bolding.
Persist command history between multiple sessions. Options passed during creation are:
process.cwd()+'/.node_shell'
Provide tab completion. Options passed during creation are:
Display help when use type "help" or when he press enter
on empty prompt. Command help is only displayed if a description was provided during the command registration. Additionnaly, a new shell.help()
function is made available. Options passed during creation are:
Register two commands, cloud9 start
and cloud9 stop
. The following properties may be provided as settings:
null
.null
."127.0.0.1"
.3000
.Shell.set('project_dir')
.Exemple:
var app = new shell.Shell();
app.configure(function() {
app.use(shell.router({
shell: app
}));
app.use(shell.cloud9({
shell: app,
ip: '0.0.0.0'
}));
app.use(shell.help({
shell: app,
introduction: true
}));
});
Important, cloud9 must be installed as a NPM module but there's a problem. At the moment, the NPM module is based on the master branch of cloud9 on GitHub and is expecteding a Node version of 0.4.1. Here's the procedure to use a newer version:
git clone https://github.com/ajaxorg/cloud9.git
git checkout -b devel origin/devel
npm link
FAQs
Command line arguments parser and stringifier
The npm package shell receives a total of 5,564 weekly downloads. As such, shell popularity was classified as popular.
We found that shell demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.