Comparing version 1.0.1 to 1.0.2
29
app.js
@@ -10,23 +10,8 @@ #! /usr/bin/env node | ||
const spinner = ora({text: 'Loading results', color: 'cyan'}).start(); | ||
// const commandLineArgs = require('command-line-args') | ||
const commandLineArgs = require('command-line-args') | ||
// const optionDefinitions = [ | ||
// { name: 'query', alias: 'q', type: String }, // the query that should be sent to the Google search | ||
// { name: 'output', alias: 'o' type: String }, // name of the JSON file to save results to | ||
// { name: 'save', alias: 's', type: String }, // name of the html file if you want to save the actual response from the html request | ||
// { name: 'limit', alias: 'l', type: Number }, // number of search results to be returned | ||
// { name: 'verbose', alias: 'v', type: Boolean }, // console.log useful statements to show what's currently taking place | ||
// { name: 'interactive', alias: 'i', type: Boolean }, // once results are returned, show them in an interactive prompt where user can scroll through them | ||
// { name: 'bold-matching-text', alias: 'b', type: Boolean}, // only takes effect when interactive (-i) flas is set as well, will bold test in results that matched the query | ||
// { name: 'stackoverflow-github-only', alias: 'X', type: Boolean }, // option to limit results to only these two sites | ||
// ] | ||
const optionDefinitions = require('./optionDefinitions') | ||
const cli_options = commandLineArgs(optionDefinitions) | ||
// const options = commandLineArgs(optionDefinitions) | ||
// process.argv.forEach(function (val, index, array) { | ||
// console.log(index + ': ' + val); | ||
// }); | ||
var query = "" | ||
// https://stackoverflow.com/questions/4351521/how-do-i-pass-command-line-arguments | ||
// first arg is 'node', second is /path/to/file/app.js, third is whatever follows afterward | ||
@@ -51,3 +36,3 @@ if (process.argv.length > 2) { | ||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:34.0) Gecko/20100101 Firefox/34.0' | ||
}//syntax%20error | ||
} | ||
} | ||
@@ -60,2 +45,6 @@ request(options, (error, response, body) => { | ||
var results = getResults(body) | ||
if (cli_options.output != null) { | ||
console.log("writing to output file! :) :) :)") | ||
fs.writeFile(cli_options.output, JSON.stringify(results, null, 2), 'utf8') | ||
} | ||
} | ||
@@ -73,3 +62,3 @@ // fs.writeFile('output.html', body, 'utf8', (err) => { | ||
googleIt(query != "" ? query : "new york penn station") | ||
googleIt(query != "" ? query : "new york penn station", cli_options.limit) | ||
@@ -76,0 +65,0 @@ function getResults(data) { |
{ | ||
"name": "google-it", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A command line utility to help retrieve, display, and store Google search results", | ||
@@ -5,0 +5,0 @@ "main": "./app.js", |
@@ -14,1 +14,26 @@ # google-it | ||
![GIF of google-it](google-it-demo.gif?raw=true "google-it") | ||
## Upcoming Features Roadmap | ||
### Command Line Arguments | ||
- [ ] *query* - the query that should be sent to the Google search | ||
- [x] *output* - name of the JSON file to save results to | ||
- [ ] *save* - name of the html file if you want to save the actual response from the html request (useful for debugging purposes) | ||
- [x] *limit* - number of search results to be returned | ||
- [ ] *verbose* - console.log useful statements to show what's currently taking place | ||
- [ ] *interactive* - once results are returned, show them in an interactive prompt where user can scroll through them | ||
- [ ] *bold-matching-text* - only takes effect when interactive (-i) flag is set as well, will bold test in results that matched the query | ||
- [ ] *stackoverflow-github-only* - option to limit results to only these two sites | ||
### Programmatic Use in NodeJS environment | ||
- [ ] something like: | ||
``` | ||
var googleIt = require('google-it') | ||
googleIt('covfefe irony').then(results => { | ||
// access to results object here | ||
}).catch(e => { | ||
// any possible errors that might have occurred (like no Internet connection) | ||
}) | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
98
39
4464406