-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* correctly handle nerf-darted env vars
- Loading branch information
Showing
10 changed files
with
670 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../nopt/bin/nopt.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
The ISC License | ||
|
||
Copyright (c) Isaac Z. Schlueter and Contributors | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env node | ||
var nopt = require('../lib/nopt') | ||
var path = require('path') | ||
var types = { num: Number, | ||
bool: Boolean, | ||
help: Boolean, | ||
list: Array, | ||
'num-list': [Number, Array], | ||
'str-list': [String, Array], | ||
'bool-list': [Boolean, Array], | ||
str: String, | ||
clear: Boolean, | ||
config: Boolean, | ||
length: Number, | ||
file: path, | ||
} | ||
var shorthands = { s: ['--str', 'astring'], | ||
b: ['--bool'], | ||
nb: ['--no-bool'], | ||
tft: ['--bool-list', '--no-bool-list', '--bool-list', 'true'], | ||
'?': ['--help'], | ||
h: ['--help'], | ||
H: ['--help'], | ||
n: ['--num', '125'], | ||
c: ['--config'], | ||
l: ['--length'], | ||
f: ['--file'], | ||
} | ||
var parsed = nopt(types | ||
, shorthands | ||
, process.argv | ||
, 2) | ||
|
||
console.log('parsed', parsed) | ||
|
||
if (parsed.help) { | ||
console.log('') | ||
console.log('nopt cli tester') | ||
console.log('') | ||
console.log('types') | ||
console.log(Object.keys(types).map(function M (t) { | ||
var type = types[t] | ||
if (Array.isArray(type)) { | ||
return [t, type.map(function (mappedType) { | ||
return mappedType.name | ||
})] | ||
} | ||
return [t, type && type.name] | ||
}).reduce(function (s, i) { | ||
s[i[0]] = i[1] | ||
return s | ||
}, {})) | ||
console.log('') | ||
console.log('shorthands') | ||
console.log(shorthands) | ||
} |
Oops, something went wrong.