Skip to content

Commit a28412f

Browse files
authored
fix: cleanup bin (#127)
1 parent 9a52cb5 commit a28412f

File tree

2 files changed

+7
-64
lines changed

2 files changed

+7
-64
lines changed

bin/nopt.js

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env node
2-
var nopt = require('../lib/nopt')
3-
var path = require('path')
4-
var types = { num: Number,
2+
const nopt = require('../lib/nopt')
3+
const path = require('path')
4+
console.log('parsed', nopt({
5+
num: Number,
56
bool: Boolean,
67
help: Boolean,
78
list: Array,
@@ -13,8 +14,8 @@ var types = { num: Number,
1314
config: Boolean,
1415
length: Number,
1516
file: path,
16-
}
17-
var shorthands = { s: ['--str', 'astring'],
17+
}, {
18+
s: ['--str', 'astring'],
1819
b: ['--bool'],
1920
nb: ['--no-bool'],
2021
tft: ['--bool-list', '--no-bool-list', '--bool-list', 'true'],
@@ -25,32 +26,4 @@ var shorthands = { s: ['--str', 'astring'],
2526
c: ['--config'],
2627
l: ['--length'],
2728
f: ['--file'],
28-
}
29-
var parsed = nopt(types
30-
, shorthands
31-
, process.argv
32-
, 2)
33-
34-
console.log('parsed', parsed)
35-
36-
if (parsed.help) {
37-
console.log('')
38-
console.log('nopt cli tester')
39-
console.log('')
40-
console.log('types')
41-
console.log(Object.keys(types).map(function M (t) {
42-
var type = types[t]
43-
if (Array.isArray(type)) {
44-
return [t, type.map(function (mappedType) {
45-
return mappedType.name
46-
})]
47-
}
48-
return [t, type && type.name]
49-
}).reduce(function (s, i) {
50-
s[i[0]] = i[1]
51-
return s
52-
}, {}))
53-
console.log('')
54-
console.log('shorthands')
55-
console.log(shorthands)
56-
}
29+
}, process.argv, 2))

docs/examples/my-program.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)