google-it
Version:
A CLI and Node.js library to help retrieve, display, and store Google search results
20 lines (14 loc) • 587 B
JavaScript
;
var commandLineArgs = require('command-line-args');
var optionDefinitions = require('./optionDefinitions');
var parseCommandLineArgs = function parseCommandLineArgs(argv) {
var cliOptions = argv.length === 3 ? {
query: argv[2]
} : commandLineArgs(optionDefinitions); // first arg is 'node', second is /path/to/file/app.js, third is whatever follows afterward
if (argv.length > 2) {
// eslint-disable-next-line prefer-destructuring
cliOptions.query = argv[2].replace('--query=', '');
}
return cliOptions;
};
module.exports = parseCommandLineArgs;