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
```
wappalyzer [url] [options]
wappalyzer <url> [options]
```
### Options
```
--browser=str Specify which headless browser to use (zombie or puppeteer)
--password=str Password to be used for basic HTTP authentication
--proxy=str Proxy URL, e.g. 'http://user:pass@proxy:8080'
--username=str Username to be used for basic HTTP authentication
--chunk-size=num Process links in chunks.
--debug Output debug messages.
--delay=ms Wait for ms milliseconds between requests.
--html-max-cols=num Limit the number of HTML characters per line processed.
--html-max-rows=num Limit the number of HTML lines processed.
--max-depth=num Don't analyse pages more than num levels deep.
--max-urls=num Exit when num URLs have been analysed.
--max-wait=ms Wait no more than ms milliseconds for page resources to load.
--pretty Pretty-print JSON output
--recursive Follow links on pages (crawler).
--user-agent=str Set the user agent string.
-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)
```

@ -9,6 +9,22 @@ const options = {};
let url;
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
arg = args.shift();
@ -16,11 +32,12 @@ while (true) { // eslint-disable-line no-constant-condition
break;
}
const matches = /--([^=]+)(?:=(.+))?/.exec(arg);
const matches = /-?-([^=]+)(?:=(.+)?)?/.exec(arg);
if (matches) {
const key = matches[1].replace(/-\w/g, _matches => _matches[1].toUpperCase());
const value = matches[2] || true;
const key = aliases[matches[1]] || matches[1].replace(/-\w/g, _matches => _matches[1].toUpperCase());
// eslint-disable-next-line no-nested-ternary
const value = matches[2] ? matches[2] : args[0] && !args[0].match(/^-/) ? args.shift() : true;
options[key] = value;
} else {
@ -28,8 +45,33 @@ while (true) { // eslint-disable-line no-constant-condition
}
}
if (!url) {
process.stderr.write('No URL specified\n');
if (!url || options.help) {
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);
}

Loading…
Cancel
Save