Skip to content

Commit

Permalink
introduce real argv parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
w33ble committed Apr 20, 2014
1 parent 47a6846 commit 1b01c6b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Information

<table>
<tr>
<tr>
<td>Package</td><td>lute</td>
</tr>
<tr>
Expand All @@ -28,13 +28,13 @@ Running 'lute' in a directory will serve that dir and set up LiveReload - no nee

Serves current directory on default port (8080). Will find an open port if it's not available

`$ lute 3000`
`$ lute -p 3000`

Serves current directory on 3000, will find an open port if not available
`-p` option specifies a specific port. Executing this serves current directory on 3000, will find an open port if not available

`$ lute open`

Serves current dir and opens in your browser
Serves current dir and opens in your browser

## TODO

Expand Down
22 changes: 4 additions & 18 deletions bin/lute.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
#!/usr/bin/env node

var argv = require('minimist')(process.argv.slice(2));
var isInt = require('../lib/util/isInt');
var serve = require('../lib/serve');
var port = (argv.p && isInt(argv.p)) ? argv.p : 8080;

var cliArgs = process.argv.slice(2);
var port = isInt(cliArgs[0]) ? cliArgs[0] : 8080;

// if a port or no args, start server

if ( isInt(cliArgs[0]) || typeof cliArgs[0] === 'undefined') {

// just start server & live reload

serve(port);

}

if (cliArgs[0] === 'open') {

serve(port, true);

}
// if a port or no args, start server
serve(port, (argv._.indexOf('open') !== -1));
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"express": "~3.4.7",
"gulp-util": "~2.2.0",
"portfinder": "~0.2.1",
"cheerio": "~0.13.1"
"cheerio": "~0.13.1",
"minimist": "0.0.8"
},
"devDependencies": {
"mocha": "*",
Expand Down

0 comments on commit 1b01c6b

Please sign in to comment.