Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seeli

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seeli - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

.goutputstream-KBLZJX

118

lib/command.js
/*jshint laxcomma:true, smarttabs: true */
/* globals: require */
'use strict';
/**

@@ -75,4 +77,4 @@ * Bass command class for creating interactive cli programs

,options:{
description:""
, usage:""
description:''
, usage:''
, args:null

@@ -85,7 +87,7 @@ , interactive: true

, default:false
, description:"Use the interactive propmts"
, description:'Use the interactive propmts'
}
,color: {
type:Boolean
,description:"Enable ANSI color in output"
,description:'Enable ANSI color in output'
,default: true

@@ -99,3 +101,3 @@ ,skip:true

, constructor: function( options ){
this.setOptions( options )
this.setOptions( options );
events.EventEmitter.call( this );

@@ -112,10 +114,10 @@ Object.defineProperties(this,{

get:function(){
var out = helpers.usage.from( this.options.flags )
var out = helpers.usage.from( this.options.flags );
return array_append(
toArray( this.options.usage ),
[
!!out ? "Options:" : ""
!!out ? 'Options:' : ''
, out
]
).join( os.EOL )
).join( os.EOL );
}

@@ -131,3 +133,3 @@ }

get: function(){
return this.options.description
return this.options.description;
}

@@ -144,3 +146,3 @@ }

if( this.parsed ){
return this.parsed
return this.parsed ;
}

@@ -152,13 +154,13 @@

// append dummy arguments for nopt
this.options.args.unshift( '', '', '' )
this.options.args.unshift( '', '', '' );
}
this.parsed = nopt( this.conf, this.shorthands, this.options.args || process.argv )
this.parsed = nopt( this.conf, this.shorthands, this.options.args || process.argv );
Object.keys( this.options.flags).forEach(function( key ){
var value = this.options.flags[ key ]
var value = this.options.flags[ key ];
this.parsed[ key ] = this.parsed.hasOwnProperty( key ) ? this.parsed[key] : value.default;
}.bind( this ))
}.bind( this ));
return this.parsed
return this.parsed;
}

@@ -176,10 +178,10 @@ }

if( this._optcache ){
return this._optcache
return this._optcache;
}
this._optcache = {};
Object.keys( this.options.flags).forEach(function( key ){
var value = this.options.flags[ key ]
this._optcache[key]=value.type
}.bind( this ))
return this._optcache
var value = this.options.flags[ key ];
this._optcache[key]=value.type;
}.bind( this ));
return this._optcache;
}

@@ -197,3 +199,3 @@ }

if( this._shcache ){
return this._shcache
return this._shcache;
}

@@ -203,7 +205,7 @@ this._shcache = {};

Object.keys(this.options.flags).forEach(function( key ){
var value = this.options.flags[key]
var value = this.options.flags[key];
if( value.shorthand ){
this._shcache[value.shorthand] = [ "--" + key ]
this._shcache[value.shorthand] = [ '--' + key ];
}
}.bind( this ))
}.bind( this ));
return this._shcache;

@@ -222,8 +224,8 @@ }

Object.keys( this.options.flags ).filter( function( flag ){
var opt = this.options.flags[flag]
var opt = this.options.flags[flag];
if( !!opt.event ){
this.emit(flag, this.argv[ flag ] )
this.emit(flag, this.argv[ flag ] );
}
}.bind( this ))
}.bind( this ));
}

@@ -238,4 +240,4 @@

, interactive: function( cmd, done ){
var questions = []
this.interactive = true
var questions = [];
this.interactive = true;
Object.keys(this.options.flags).forEach(function( flag ){

@@ -245,4 +247,4 @@ var current = this.options.flags[flag];

if( current.skip ){
return
};
return;
}

@@ -252,5 +254,5 @@ var arg = {

,name: flag
,message: flag + ": " + current.description
,message: flag + ': ' + current.description
,default: current.default || null
}
};

@@ -267,12 +269,12 @@ if( current.when ){

if( current.choices ){
arg.type = 'list'
arg.choices = current.choices
arg.type = 'list';
arg.choices = current.choices;
}
questions.push( arg );
}
}.bind( this ))
}.bind( this ));
inquirer.prompt( questions,function( answers ){
this.options.run.call(this, null, answers, done )
}.bind( this ))
this.options.run.call(this, null, answers, done );
}.bind( this ));
}

@@ -290,3 +292,3 @@

this.parsed = null;
this.interactive = !!this.options.interactive
this.interactive = !!this.options.interactive;
return this;

@@ -306,30 +308,31 @@ }

var done = function( err, content ){
content = !!this.argv.color ? content : chalk.stripColor( content );
if( err ){
/**
* @name moduleName.Command#shake
* dispatched when the command has failed in some way
* @name command.Command#error
* @event
* @param {Event} e
* @param {Boolean} [e.withIce=false]
* @param {Error} e
*/
this.emit('error', err )
this.emit('error', err );
} else{
/**
* @name moduleName.Command#shake
* dispatched when the command has sucessfully completed
* @name command.Command#content
* @event
* @param {Event} e
* @param {Boolean} [e.withIce=false]
* @param {Error} e
*/
this.emit('content', content)
this.emit('content', content);
}
callback && callback( err, content )
process.stdout.write(os.EOL)
callback && callback( err, content );
process.stdout.write(os.EOL);
}.bind( this );
chalk.enabled = this.argv.color;
if( this.argv.interactive ) {
if( this.options.interactive ){
this.dispatch()
return this.interactive.call( this, null, done )
this.dispatch();
return this.interactive.call( this, null, done );
} else{
console.log('interactive mode - not availible\n'.yellow )
console.log('interactive mode - not availible\n'.yellow );
}

@@ -339,10 +342,9 @@

this.dispatch()
var result = this.options.run.call(this, cmd, this.argv, done )
chalk.enabled = true;
return result;
this.dispatch();
var result = this.options.run.call(this, cmd, this.argv, done );
return !!this.argv.color ? result : chalk.stripColor( result );
}
, colorize: function( color, text ){
return ( this.argv.color && chalk[color] ) ? chalk[color]( text ) : text
return ( this.argv.color && chalk[color] ) ? chalk[color]( text ) : text;
}

@@ -349,0 +351,0 @@

@@ -73,3 +73,11 @@ /*jshint laxcomma:true, smarttabs: true */

try{
var help = instance.description + os.EOL + instance.usage
var help = [instance.description];
var breaker = '', len = instance.description.length;
while( len-- ){
breaker += '='
}
help.push( breaker, instance.usage )
help = help.join( os.EOL )
} catch( e ){

@@ -79,2 +87,3 @@ var help = "no help found for " + cmd + " "+ e.message

done( null, help )
return;

@@ -81,0 +90,0 @@ }

@@ -38,3 +38,3 @@ /*jshint laxcomma:true, smarttabs: true */

return_value = [];
style = !!plain ? function(input){ return input } : chalk.blue;
style = !!plain ? function(input){ return input } : chalk.green;

@@ -50,3 +50,3 @@ Object.keys(flags).forEach(function( flag ){

, style(type)
, typeof config.default === 'undefined' ? "" : util.format("[%s]",config.default)
, typeof config.default === 'undefined' ? "" : util.format("[%s]", chalk.bold( config.default ) )
,config.description || ''

@@ -53,0 +53,0 @@ ))

@@ -25,9 +25,10 @@ /*jshint laxcomma:true, smarttabs: true */

, clidomain
, colors
, help
, commands; // The primary Class exports from the module
colors = ['red', 'blue','green', 'yellow','bold', 'grey', 'dim', 'black', 'magenta']
clidomain = domain.create()
clidomain.on('error', function(err, domn ){
console.log(chalk.bold( "something bad happened - %s : %s", err.name, err.message ) )
console.log( chalk.bold( util.format( "something bad happened - %s : %s", err.name, err.message) ) )
if( parsed && parsed.traceback ){

@@ -66,2 +67,5 @@ console.log( chalk.red( err.stack ) )

exports.commands = commands
colors.forEach( function( color ){
exports[color] = chalk[color].bind( chalk )
})
exports.run = function( ){

@@ -68,0 +72,0 @@ parsed = nopt( opts, shorthands );

{
"name": "seeli",
"version": "0.1.0",
"version": "0.1.1",
"description": "Object oriented, flexible CLI tools",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -69,8 +69,8 @@ node-seeli ( C-L-I )

-----|:-----:|--------|-------------
**description** | `String` | `""`
**args** | `Array` | `null`
**interactive** | `Boolean` | `true`
**usage** | `String` / `Array` | `""`
**flags** | `Object` | `{}`
**run** | `Function` | `no-op`
**description** | `String` | `""` | Used to render help output
**args** | `Array` | `null` | if supplied, `agrs` will be used instead of `process.argv`
**interactive** | `Boolean` | `true` | If set to false, the flag will be excluded from the interactive prompts
**usage** | `String` / `Array` | `""` | A string or array of strings used to generate help text
**flags** | `Object` | `{}` | key value pairs used to control the command where keys are the name of the flag and the values is a configuration object for the flag
**run** | `Function` | `no-op` | A function used as the body of the command. it will be passed a `name`, a `data` object containing the processed values from the command input and a `done` function to be called when the command is done.

@@ -77,0 +77,0 @@ ### Flag Options

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc