Skip to content

Commit

Permalink
fix: cleanup bin (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys authored Jun 15, 2023
1 parent 9a52cb5 commit a28412f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 64 deletions.
41 changes: 7 additions & 34 deletions bin/nopt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node
var nopt = require('../lib/nopt')
var path = require('path')
var types = { num: Number,
const nopt = require('../lib/nopt')
const path = require('path')
console.log('parsed', nopt({
num: Number,
bool: Boolean,
help: Boolean,
list: Array,
Expand All @@ -13,8 +14,8 @@ var types = { num: Number,
config: Boolean,
length: Number,
file: path,
}
var shorthands = { s: ['--str', 'astring'],
}, {
s: ['--str', 'astring'],
b: ['--bool'],
nb: ['--no-bool'],
tft: ['--bool-list', '--no-bool-list', '--bool-list', 'true'],
Expand All @@ -25,32 +26,4 @@ var shorthands = { s: ['--str', 'astring'],
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)
}
}, process.argv, 2))
30 changes: 0 additions & 30 deletions docs/examples/my-program.js

This file was deleted.

0 comments on commit a28412f

Please sign in to comment.