-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
executable file
·31 lines (25 loc) · 882 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env node
/**
* Console interface for wgrep
*/
const co = require('co');
const wgrep = require('./wgrep');
const program = require('commander');
const { version } = require('./package.json');
(async () => {
program
.arguments('<regex> <url>')
.version(version, '-V, --version')
.option('-d, --directory <directory>', 'The output directory', 'output')
.option('-u, --username <username>', 'The user to authenticate as')
.action(function( regex, url ) {
const options = program.opts()
co(async function () {
wgrep.ensureOutput(options.directory)
console.log(`Calling for "${regex}" in "${options.directory}" from "${url}" with user "${options.username}"`)
await wgrep.download( url, options.directory );
wgrep.show(wgrep.find( options.directory, regex ))
});
})
.parse(process.argv)
})()