Comparing version 1.0.3 to 1.0.4
26
cli.js
@@ -9,2 +9,7 @@ #!/usr/bin/env node | ||
}) | ||
.option('j', { | ||
alias: 'json', | ||
type: 'boolean', | ||
desc: 'Output as JSON' | ||
}) | ||
.demandCommand(1) | ||
@@ -15,15 +20,30 @@ .argv; | ||
libAqi.getSensor(argv._[0]).then(async function (sensor) { | ||
var sensorId = argv._[0]; | ||
libAqi.getSensor(sensorId).then(async function (sensor) { | ||
var aqi = await libAqi.getAQI(sensor); | ||
var output = aqi; | ||
aqiClass = null; | ||
if (argv.class) { | ||
var aqiClass = libAqi.getAQIClass(aqi); | ||
aqiClass = libAqi.getAQIClass(aqi); | ||
output = `${aqi} (${aqiClass})`; | ||
} | ||
console.log(output); | ||
if (argv.json) { | ||
var outputJson = { | ||
aqi: aqi, | ||
sensorId: sensorId, | ||
}; | ||
if (aqiClass) { | ||
outputJson.class = aqiClass; | ||
} | ||
console.log(JSON.stringify(outputJson, null, 2)); | ||
} else { | ||
console.log(output); | ||
} | ||
}).catch(err => { | ||
console.error(err); | ||
}); |
{ | ||
"name": "purpleair", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Retrieve AQI (with AQandU conversion) from a Purpleair sensor via the CLI or as a library to your node script", | ||
@@ -5,0 +5,0 @@ "keywords": ["purple air", "purpleair", "aqi", "aqandu"], |
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
6981
134