Add short options and help output to NPM driver

main
Elbert Alias 5 years ago
parent 311719e87e
commit f2a4297859

@ -28,27 +28,28 @@ $ npm i puppeteer@^2.0.0
## Run from the command line ## Run from the command line
``` ```
wappalyzer [url] [options] wappalyzer <url> [options]
``` ```
### Options ### Options
``` ```
--browser=str Specify which headless browser to use (zombie or puppeteer) -b, --browser=... Specify which headless browser to use (zombie or puppeteer)
--password=str Password to be used for basic HTTP authentication -c, --chunk-size=... Process links in chunks
--proxy=str Proxy URL, e.g. 'http://user:pass@proxy:8080' -d, --debug Output debug messages
--username=str Username to be used for basic HTTP authentication -t, --delay=ms Wait for ms milliseconds between requests
--chunk-size=num Process links in chunks. -h, --help This text
--debug Output debug messages. --html-max-cols=... Limit the number of HTML characters per line processed
--delay=ms Wait for ms milliseconds between requests. --html-max-rows=... Limit the number of HTML lines processed
--html-max-cols=num Limit the number of HTML characters per line processed. -D, --max-depth=... Don't analyse pages more than num levels deep
--html-max-rows=num Limit the number of HTML lines processed. -m, --max-urls=... Exit when num URLs have been analysed
--max-depth=num Don't analyse pages more than num levels deep. -w, --max-wait=... Wait no more than ms milliseconds for page resources to load
--max-urls=num Exit when num URLs have been analysed. -p, --password=... Password to be used for basic HTTP authentication (zombie only)
--max-wait=ms Wait no more than ms milliseconds for page resources to load. -P, --pretty Pretty-print JSON output
--pretty Pretty-print JSON output --proxy=... Proxy URL, e.g. 'http://user:pass@proxy:8080' (zombie only)
--recursive Follow links on pages (crawler). -r, --recursive Follow links on pages (crawler)
--user-agent=str Set the user agent string. -a, --user-agent=... Set the user agent string
-u, --username=... Username to be used for basic HTTP authentication (zombie only)
``` ```

@ -9,6 +9,22 @@ const options = {};
let url; let url;
let arg; let arg;
const aliases = {
a: 'userAgent',
b: 'browser',
c: 'chunkSize',
d: 'debug',
t: 'delay',
h: 'help',
D: 'maxDepth',
m: 'maxUrls',
p: 'password',
P: 'pretty',
r: 'recursive',
u: 'username',
w: 'maxWait',
};
while (true) { // eslint-disable-line no-constant-condition while (true) { // eslint-disable-line no-constant-condition
arg = args.shift(); arg = args.shift();
@ -16,11 +32,12 @@ while (true) { // eslint-disable-line no-constant-condition
break; break;
} }
const matches = /--([^=]+)(?:=(.+))?/.exec(arg); const matches = /-?-([^=]+)(?:=(.+)?)?/.exec(arg);
if (matches) { if (matches) {
const key = matches[1].replace(/-\w/g, _matches => _matches[1].toUpperCase()); const key = aliases[matches[1]] || matches[1].replace(/-\w/g, _matches => _matches[1].toUpperCase());
const value = matches[2] || true; // eslint-disable-next-line no-nested-ternary
const value = matches[2] ? matches[2] : args[0] && !args[0].match(/^-/) ? args.shift() : true;
options[key] = value; options[key] = value;
} else { } else {
@ -28,8 +45,33 @@ while (true) { // eslint-disable-line no-constant-condition
} }
} }
if (!url) { if (!url || options.help) {
process.stderr.write('No URL specified\n'); process.stdout.write(`Usage:
wappalyzer <url> [options]
Examples:
wappalyzer https://www.example.com
node cli.js https://www.example.com -b puppeteer -r -D 3 -m 50
docker wappalyzer/cli https://www.example.com --pretty
Options:
-b, --browser=... Specify which headless browser to use (zombie or puppeteer)
-c, --chunk-size=... Process links in chunks
-d, --debug Output debug messages
-t, --delay=ms Wait for ms milliseconds between requests
-h, --help This text
--html-max-cols=... Limit the number of HTML characters per line processed
--html-max-rows=... Limit the number of HTML lines processed
-D, --max-depth=... Don't analyse pages more than num levels deep
-m, --max-urls=... Exit when num URLs have been analysed
-w, --max-wait=... Wait no more than ms milliseconds for page resources to load
-p, --password=... Password to be used for basic HTTP authentication (zombie only)
-P, --pretty Pretty-print JSON output
--proxy=... Proxy URL, e.g. 'http://user:pass@proxy:8080' (zombie only)
-r, --recursive Follow links on pages (crawler)
-a, --user-agent=... Set the user agent string
-u, --username=... Username to be used for basic HTTP authentication (zombie only)
`);
process.exit(1); process.exit(1);
} }

Loading…
Cancel
Save