Skip to content

Commit

Permalink
Simplify bin flags (#291)
Browse files Browse the repository at this point in the history
* remove boolean type; is naturally

* replace string-cast w/ defaults + implicit casts

- `http` uses ‘::’ for ‘host’ if nully
  • Loading branch information
lukeed authored and leo committed Aug 1, 2017
1 parent c5da182 commit ef42e4a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/micro.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ const logError = require('../lib/error')

// Check if the user defined any options
const flags = parseArgs(process.argv.slice(2), {
string: ['host', 'port'],
boolean: ['help', 'version'],
default: {
host: '::',
port: 3000
},
alias: {
p: 'port',
H: 'host',
Expand Down Expand Up @@ -88,7 +90,7 @@ server.on('error', err => {
process.exit(1)
})

server.listen(flags.port || 3000, flags.host, () => {
server.listen(flags.port, flags.host, () => {
const details = server.address()

process.on('SIGTERM', () => {
Expand Down

0 comments on commit ef42e4a

Please sign in to comment.