Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update style, readme, travis config, pipe help to stderr
- Loading branch information
1 parent
d4d6b32
commit 933929f
Showing
9 changed files
with
166 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- "iojs" | ||
- "4.0" | ||
- "0.12" | ||
- "0.11" | ||
- "0.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,92 @@ | ||
#!/usr/bin/env node | ||
|
||
var path = require('path') | ||
, fs = require('fs') | ||
var fs = require('fs') | ||
|
||
var nopt = require('nopt') | ||
|
||
var wackage = require('../package.json') | ||
, wack = require('../') | ||
var wack = require('../') | ||
|
||
var wackStream | ||
|
||
var noptions = { | ||
dir: String | ||
, ignoredir: String | ||
, ignorecase: Boolean | ||
, knowntypes: Boolean | ||
, maxcount: Number | ||
, norecurse: Boolean | ||
, invertmatch: Boolean | ||
, type: String | ||
, notype: String | ||
, justone: Boolean | ||
, nocolor: Boolean | ||
, thpppt: Boolean | ||
, version: Boolean | ||
, help: Boolean | ||
dir: String, | ||
ignoredir: String, | ||
ignorecase: Boolean, | ||
knowntypes: Boolean, | ||
maxcount: Number, | ||
norecurse: Boolean, | ||
invertmatch: Boolean, | ||
type: String, | ||
notype: String, | ||
justone: Boolean, | ||
nocolor: Boolean, | ||
thpppt: Boolean, | ||
version: Boolean, | ||
help: Boolean | ||
} | ||
|
||
var shorts = { | ||
d: ['--dir'] | ||
, D: ['--ignoredir'] | ||
, i: ['--ignorecase'] | ||
, k: ['--knowntypes'] | ||
, m: ['--maxcount'] | ||
, n: ['--norecurse'] | ||
, v: ['--invertmatch'] | ||
, t: ['--type'] | ||
, T: ['--notype'] | ||
, '1': ['--justone'] | ||
, C: ['--nocolor'] | ||
, h: ['--help'] | ||
, V: ['--version'] | ||
'd': ['--dir'], | ||
'D': ['--ignoredir'], | ||
'i': ['--ignorecase'], | ||
'k': ['--knowntypes'], | ||
'm': ['--maxcount'], | ||
'n': ['--norecurse'], | ||
'v': ['--invertmatch'], | ||
't': ['--type'], | ||
'T': ['--notype'], | ||
'1': ['--justone'], | ||
'C': ['--nocolor'], | ||
'h': ['--help'], | ||
'V': ['--version'] | ||
} | ||
|
||
var options = nopt(noptions, shorts, process.argv) | ||
if (require.main === module) { | ||
bin() | ||
} | ||
|
||
module.exports = bin | ||
|
||
function bin () { | ||
var options = nopt(noptions, shorts, process.argv) | ||
var wackStream | ||
|
||
options.pattern = options.argv.remain[0] | ||
|
||
if (options.version) { | ||
return version() | ||
} | ||
|
||
options.pattern = options.argv.remain[0] | ||
if (options.help || !options.pattern) { | ||
return help() | ||
} | ||
|
||
if(options.version) return version() | ||
if(options.help) return help() | ||
if(options.thpppt) return cat() | ||
if(!options.pattern) return help() | ||
if (options.thpppt) { | ||
return cat() | ||
} | ||
|
||
function version() { | ||
wackStream = wack(options) | ||
wackStream.pipe(wackStream.prettify()).pipe(process.stdout) | ||
wackStream.write(options.dir || process.cwd()) | ||
} | ||
|
||
function version () { | ||
console.log('wack version ' + wackage.version) | ||
} | ||
|
||
function help() { | ||
function help () { | ||
version() | ||
fs.createReadStream(path.join(__dirname, '..', 'help.txt')) | ||
.pipe(process.stdout) | ||
.pipe(process.stderr) | ||
} | ||
|
||
function cat() { | ||
function cat () { | ||
process.stdout.write([ | ||
' _ /|' | ||
, ' \\\'o.O\'' | ||
, ' =(___)=' | ||
, ' U wack --thpppt!' | ||
, '' | ||
' _ /|', | ||
' \\\'o.O\'', | ||
' =(___)=', | ||
' U wack --thpppt!', | ||
'' | ||
].join('\n')) | ||
} | ||
|
||
wackStream = wack(options) | ||
|
||
wackStream.pipe(wackStream.prettify()).pipe(process.stdout) | ||
|
||
wackStream.write(options.dir || process.cwd()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.