Skip to content

Commit

Permalink
Require one argument for optional parameters
Browse files Browse the repository at this point in the history
When an optional parameter like `-p` that requires an argument is used but an argument is not passed, this will cause the app to fail as expected instead of using a random value. For example, port was being set to 3000 instead of the default 5401.

This hopefully addresses #145.
  • Loading branch information
josebolos committed Oct 19, 2017
1 parent 1c9432b commit 3f1ecc2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bin/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ var yargs = require('yargs');
var args = yargs
.options('p', {
alias: 'port',
nargs: 1,
default: 5401,
type: 'number',
describe: 'Port number'
})
.options('d', {
alias: 'data',
nargs: 1,
default: './data',
type: 'string',
describe: 'The path to look for sample data in'
})
.options('l', {
alias: 'latency',
nargs: 1,
default: 0,
type: 'number',
describe: 'Add milliseconds of latency to the request'
Expand Down

0 comments on commit 3f1ecc2

Please sign in to comment.