command-line-args
Advanced tools
Comparing version 2.1.1 to 2.1.2
#!/usr/bin/env node | ||
'use strict' | ||
var cliArgs = require('../') | ||
var commandLineArgs = require('../') | ||
var os = require('os') | ||
@@ -19,3 +19,3 @@ var fs = require('fs') | ||
var cli = cliArgs(cliOptions) | ||
var cli = commandLineArgs(cliOptions) | ||
try { | ||
@@ -22,0 +22,0 @@ console.log(cli.parse()) |
module.exports = [ | ||
{ name: 'files', type: String, multiple: true, value: [ 'one.js' ] }, | ||
{ name: 'max', type: Number, value: 3 } | ||
{ name: 'files', type: String, multiple: true, defaultValue: [ 'one.js' ] }, | ||
{ name: 'max', type: Number, defaultValue: 3 } | ||
] |
@@ -35,6 +35,2 @@ /* | ||
if (valid) { | ||
console.log("your options are valid", options) | ||
} else { | ||
console.log("your options are invalid", options) | ||
} | ||
console.log('your options are', valid ? 'valid' : 'invalid', options) |
@@ -86,5 +86,5 @@ 'use strict' | ||
function halt(name, message){ | ||
function halt (name, message) { | ||
var err = new Error(message) | ||
err.name = name; | ||
err.name = name | ||
throw err | ||
@@ -91,0 +91,0 @@ } |
@@ -75,3 +75,3 @@ 'use strict' | ||
var duplicateName = hasDuplicates(this.map(def => def.name)) | ||
if (duplicateName){ | ||
if (duplicateName) { | ||
halt( | ||
@@ -84,3 +84,3 @@ 'DUPLICATE_NAME', | ||
var duplicateAlias = hasDuplicates(this.map(def => def.alias)) | ||
if (duplicateAlias){ | ||
if (duplicateAlias) { | ||
halt( | ||
@@ -93,3 +93,3 @@ 'DUPLICATE_ALIAS', | ||
var duplicateDefaultOption = hasDuplicates(this.map(def => def.defaultOption)) | ||
if (duplicateDefaultOption){ | ||
if (duplicateDefaultOption) { | ||
halt( | ||
@@ -136,5 +136,5 @@ 'DUPLICATE_DEFAULT_OPTION', | ||
function halt(name, message){ | ||
function halt (name, message) { | ||
var err = new Error(message) | ||
err.name = name; | ||
err.name = name | ||
throw err | ||
@@ -147,5 +147,5 @@ } | ||
function hasDuplicates(array){ | ||
function hasDuplicates (array) { | ||
var items = {} | ||
for (var i = 0; i < array.length; i++){ | ||
for (var i = 0; i < array.length; i++) { | ||
var value = array[i] | ||
@@ -152,0 +152,0 @@ if (items[value]) { |
{ | ||
"name": "command-line-args", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "A library to collect command-line args and generate a usage guide.", | ||
@@ -26,3 +26,3 @@ "repository": "https://github.com/75lb/command-line-args.git", | ||
], | ||
"author": "Lloyd Brookes", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"license": "MIT", | ||
@@ -29,0 +29,0 @@ "devDependencies": { |
@@ -11,2 +11,4 @@ [![view on npm](http://img.shields.io/npm/v/command-line-args.svg)](https://www.npmjs.org/package/command-line-args) | ||
*Alternatively, this library is extended by [command-line-commands](https://github.com/75lb/command-line-commands), should your app require a git-like command interface.* | ||
## Synopsis | ||
@@ -13,0 +15,0 @@ You can set options using the main notation standards (getopt, getopt_long, etc.). These commands are all equivalent, setting the same values: |
@@ -13,3 +13,3 @@ var test = require('tape') | ||
var argv = [ '-v' ] | ||
var cli = new cliArgs(optionDefinitions) | ||
var cli = new cliArgs(optionDefinitions) // eslint-disable-line new-cap | ||
t.deepEqual(cli.parse(argv), { | ||
@@ -16,0 +16,0 @@ verbose: true |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78885
384
1822