Socket
Socket
Sign inDemoInstall

google-it

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-it - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

google-it-output-no-display.gif

20

googleIt.js

@@ -22,3 +22,3 @@ var request = require('request')

} else {
var results = getResults(body)
var results = getResults(body, config['no-display'])
if (output !== undefined) {

@@ -44,3 +44,3 @@ fs.writeFile(output, JSON.stringify(results, null, 2), 'utf8', (err) => {

function getResults(data) {
function getResults(data, noDisplay) {
const $ = cheerio.load(data)

@@ -76,9 +76,11 @@ var results = []

results.forEach((result, i) => {
console.log(result.title.blue)
console.log(result.link.green)
console.log(result.snippet)
console.log("\n")
// console.log(`#${i}: ${result.title} (${result.link})`)
})
if (!noDisplay) {
results.forEach((result, i) => {
console.log(result.title.blue)
console.log(result.link.green)
console.log(result.snippet)
console.log("\n")
// console.log(`#${i}: ${result.title} (${result.link})`)
})
}
return results

@@ -85,0 +87,0 @@ }

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) flag 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
// the query that should be sent to the Google search
{ name: 'query', alias: 'q', type: String },
// name of the JSON file to save results to
{ name: 'output', alias: 'o', type: String },
// prevent results from appearing in the terminal output. Should only be used
// with --output (-o) command when saving results to a file
{ name: 'no-display', alias: 'n', type: Boolean},
// name of the html file if you want to save the actual response from the
// html request
{ name: 'save', alias: 's', type: String },
// number of search results to be returned
{ name: 'limit', alias: 'l', type: Number },
// console.log useful statements to show what's currently taking place
{ name: 'verbose', alias: 'v', type: Boolean },
// once results are returned, show them in an interactive prompt where user
// can scroll through them
{ name: 'interactive', alias: 'i', type: Boolean },
// only takes effect when interactive (-i) flag is set as well, will bold
// test in results that matched the query
{ name: 'bold-matching-text', alias: 'b', type: Boolean},
// option to limit results to only these two sites
{ name: 'stackoverflow-github-only', alias: 'X', type: Boolean }
]
module.exports = optionDefinitions
{
"name": "google-it",
"version": "1.0.3",
"version": "1.0.4",
"description": "A command line utility to help retrieve, display, and store Google search results",

@@ -5,0 +5,0 @@ "main": "./app.js",

@@ -15,8 +15,14 @@ # google-it ![Travis-CI](https://travis-ci.org/PatNeedham/google-it.svg?branch=master)

Prevent display in the terminal, and save results to a JSON file:
`$ google-it "PWAs with react-router and redux" -o results.json -n`
![GIF of google-it w/o display, results saved to file](google-it-output-no-display.gif?raw=true "google-it")
## Upcoming Features Roadmap
### Command Line Arguments
- [ ] *query* - the query that should be sent to the Google search
- [x] *query* - the query that should be sent to the Google search
- [x] *output* - name of the JSON file to save results to
- [ ] *no-display* - prevent results from appearing in the terminal output. Should only be used with --output (-o) command when saving results to a file
- [x] *no-display* - prevent results from appearing in the terminal output. Should only be used with --output (-o) command when saving results to a file
- [ ] *save* - name of the html file if you want to save the actual response from the html request (useful for debugging purposes)

@@ -23,0 +29,0 @@ - [x] *limit* - number of search results to be returned

function validateCLIArguments(args) {
if (!args['query']) {
return {valid: false, 'Error': 'Missing query'}
return {
valid: false,
'Error': 'Missing query'
}
} else if (args['output'] && typeof args['output'] !== 'string') {
return {valid: false, 'Error': 'output argument must be string'}
return {
valid: false,
'Error': 'output argument must be string'
}
} else if (args['output'] && !args['output'].endsWith('.json')) {
return {valid: false, 'Error': 'output argument must end in .json'}
return {
valid: false,
'Error': 'output argument must end in .json'
}
} else if (args['no-display'] && !args['output']) {
return {
valid: false,
'Error': 'can only use --no-display when --output is used as well'
}
} else {
return {valid: true}
return {
valid: true
}
}

@@ -11,0 +27,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc