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

commist

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commist - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

5

example.js
var program = require('./')()
, minimist = require('minimist')
, result

@@ -9,2 +10,6 @@

})
.register('args', function(args) {
args = minimist(args)
console.log('just do', args)
})
.register('abcde code', function(args) {

@@ -11,0 +16,0 @@ console.log('doing something', args)

20

index.js

@@ -27,4 +27,3 @@ /*

var minimist = require('minimist')
, leven = require('leven')
var leven = require('leven')

@@ -57,7 +56,6 @@ function commist() {

function parse(args) {
var argv = minimist(args)
, matching = lookup(argv._.join(' '))
var matching = lookup(args)
if (matching.length > 0) {
matching[0].call(argv)
matching[0].call(args)

@@ -68,3 +66,3 @@ // return null if there is nothing left to do

return argv
return args
}

@@ -105,11 +103,3 @@

Command.prototype.call = function call(argv) {
var that = this
this.func(Object.keys(argv).reduce(function(obj, key) {
if (key === '_')
obj._ = argv._.slice(that.length)
else
obj[key] = argv[key]
return obj
}, {}))
this.func(argv.slice(this.length))
}

@@ -116,0 +106,0 @@

{
"name": "commist",
"version": "0.2.0",
"version": "1.0.0",
"description": "Build your commands on minimist!",

@@ -25,5 +25,6 @@ "main": "index.js",

"devDependencies": {
"minimist": "^1.1.0",
"pre-commit": "0.0.9",
"tap": "^0.4.12"
"tape": "^3.0.3"
}
}

@@ -5,6 +5,7 @@ commist

Build command line application with multiple commands the easy way.
Built on minimist.
To be used with [minimist](http://npm.im/minimist).
```js
var program = require('commist')()
, minimist = require('minimist')
, result

@@ -16,2 +17,6 @@

})
.register('args', function(args) {
args = minimist(args)
console.log('just do', args)
})
.register('abcde code', function(args) {

@@ -18,0 +23,0 @@ console.log('doing something', args)

var test = require('tap').test
var test = require('tape').test
, commist = require('./')
, minimist = require('minimist')
test('parsing as minimist', function(t) {
var program = commist()
, args = ['a', 'b', 'c']
function minitest(args) {
t.deepEqual(program.parse(args), minimist(args))
}
minitest(['a', 'b', 'c'])
minitest(['a', '-b', '-c', 23])
minitest(['a', '-bde'])
t.end()
})
test('registering a command', function(t) {

@@ -28,3 +13,3 @@ t.plan(2)

program.register('hello', function(args) {
t.deepEqual(args, { _: ['a'], x: 23 })
t.deepEqual(args, ['a', '-x', '23'])
})

@@ -48,3 +33,3 @@

program.register('world', function(args) {
t.deepEqual(args, { _: ['a'], x: 23 })
t.deepEqual(args, ['a', '-x', '23'])
})

@@ -62,3 +47,3 @@

program.register('hello', function(args) {
t.deepEqual(args, { _: ['a'], x: 23 })
t.deepEqual(args, ['a', '-x', '23'])
})

@@ -84,3 +69,3 @@

program.register('hello world', function(args) {
t.deepEqual(args, { _: ['a'], x: 23 })
t.deepEqual(args, ['a', '-x', '23'])
})

@@ -98,3 +83,3 @@

program.register('hello', function(args) {
t.deepEqual(args, { _: ['a'], x: 23 })
t.deepEqual(args, ['a', '-x', '23'])
})

@@ -173,3 +158,3 @@

program.register('hello', function(args) {
t.deepEqual(args, { _: ['a'], x: 23 })
t.deepEqual(args, ['a', '-x', '23'])
})

@@ -176,0 +161,0 @@

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