Comparing version 1.0.0 to 2.0.0
36
cli.js
@@ -12,8 +12,17 @@ #!/usr/bin/env node | ||
const error = chalk.bold.red; | ||
let input; | ||
function fail(err) { | ||
process.stdout.write(`${error('\u2716')} ${err}\n`); | ||
process.stdout.write(`${error('\u2716')} ${err.message}\n`); | ||
process.exit(1); | ||
} | ||
function showSuccess(dados) { | ||
const head = Object.keys(dados); | ||
const values = head.map(k => dados[k]); | ||
const table = new Table({head}); | ||
table.push(values); | ||
process.stdout.write(`${table.toString()}\n`); | ||
} | ||
function success(res) { | ||
@@ -26,7 +35,6 @@ if (res.hasOwnProperty('success')) { | ||
} | ||
const head = Object.keys(res); | ||
const values = head.map(k => res[k]); | ||
const table = new Table({head}); | ||
table.push(values); | ||
process.stdout.write(`${table.toString()}\n`); | ||
for (const dados of res.dados) { | ||
dados.req = res.req; | ||
showSuccess(dados); | ||
} | ||
process.exit(); | ||
@@ -37,9 +45,7 @@ } | ||
.version(pkg.version) | ||
.usage('<zipcode>') | ||
.description('Search address using zip code') | ||
.arguments('<zipcode>') | ||
.action(zipcode => { | ||
consulta(zipcode) | ||
.then(success) | ||
.catch(fail); | ||
.description('Busca por informações de uma localidade através do endereço ou CEP') | ||
.usage('<input>') | ||
.arguments('<input>') | ||
.action(req => { | ||
input = String(req); | ||
}) | ||
@@ -51,1 +57,5 @@ .parse(process.argv); | ||
} | ||
consulta(input) | ||
.then(success) | ||
.catch(fail); |
{ | ||
"name": "io-cep-cli", | ||
"version": "1.0.0", | ||
"description": "Search address using zip code through Correios", | ||
"version": "2.0.0", | ||
"description": "Busca por informações de uma localidade através do endereço ou CEP utilizando os Correios", | ||
"keywords": [ | ||
@@ -24,13 +24,18 @@ "cli-app", | ||
}, | ||
"main": "cli.js", | ||
"directories": { | ||
"man": "./man" | ||
}, | ||
"files": [ | ||
"cli.js", | ||
"man" | ||
], | ||
"preferGlobal": true, | ||
"bin": { | ||
"cep": "cli.js" | ||
"correios": "./cli.js" | ||
}, | ||
"man" : "./man/correios.1", | ||
"repository": "lagden/io-cep-cli", | ||
"scripts": { | ||
"pretest": "xo", | ||
"test": "mocha --reporter spec --require should", | ||
"prepublish": "npm test", | ||
"start": "watch xo" | ||
"build-man": "mdast doc/*.?.md --config-path .mdastrc-man --quiet", | ||
"test": "ava" | ||
}, | ||
@@ -41,5 +46,5 @@ "engines": { | ||
"devDependencies": { | ||
"mocha": "*", | ||
"should": "*", | ||
"watch": "^0.16.0", | ||
"ava": "^0.2.0", | ||
"mdast": "^2.1.0", | ||
"mdast-man": "^1.1.1", | ||
"xo": "^0.10.0" | ||
@@ -51,3 +56,3 @@ }, | ||
"commander": "^2.8.1", | ||
"io-cep": "^0.5.3" | ||
"io-cep": "^2.1.1" | ||
}, | ||
@@ -61,12 +66,24 @@ "xo": { | ||
"rules": { | ||
"arrow-parens": [2, "as-needed"], | ||
"prefer-reflect": [2, { | ||
"exceptions": ["delete"] | ||
}], | ||
"new-cap": [2, { | ||
"newIsCap": true, | ||
"capIsNew": false | ||
}] | ||
"arrow-parens": [ | ||
2, | ||
"as-needed" | ||
], | ||
"prefer-reflect": [ | ||
2, | ||
{ | ||
"exceptions": [ | ||
"delete" | ||
] | ||
} | ||
], | ||
"new-cap": [ | ||
2, | ||
{ | ||
"newIsCap": true, | ||
"capIsNew": false | ||
} | ||
], | ||
"lines-around-comment": 0 | ||
} | ||
} | ||
} |
@@ -1,15 +0,9 @@ | ||
# io-cep-cli | ||
[![NPM version](https://img.shields.io/npm/v/io-cep-cli.svg)](https://www.npmjs.com/package/io-cep-cli) | ||
[![Build Status](https://travis-ci.org/lagden/io-cep-cli.svg?branch=1.0.0)](https://travis-ci.org/lagden/io-cep-cli) | ||
# io-cep-cli [![NPM version](https://img.shields.io/npm/v/io-cep-cli.svg)](https://www.npmjs.com/package/io-cep-cli) | ||
[![Build Status](https://travis-ci.org/lagden/io-cep-cli.svg?branch=2.0.0)](https://travis-ci.org/lagden/io-cep-cli) | ||
[![Dependency Status](https://david-dm.org/lagden/io-cep-cli.svg)](https://david-dm.org/lagden/io-cep-cli) | ||
[![devDependency Status](https://david-dm.org/lagden/io-cep-cli/dev-status.svg)](https://david-dm.org/lagden/io-cep-cli#info=devDependencies) | ||
> Search address using zip code through Correios | ||
> Busca por informações de uma localidade através do endereço ou CEP utilizando os [Correios](http://www.correios.com.br/) | ||
## CLI | ||
![Demo cep CLI](https://raw.githubusercontent.com/lagden/io-cep-cli/master/demo.gif) | ||
#### Install | ||
@@ -24,10 +18,12 @@ | ||
### Por CEP | ||
``` | ||
$ cep 04080001 | ||
$ correios 04080001 | ||
``` | ||
or | ||
### Por endereço | ||
``` | ||
$ cep 04080-001 | ||
$ correios "Rua Primo Modolin" | ||
``` | ||
@@ -34,0 +30,0 @@ |
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
5622
47
34
+ Addedcheerio@0.22.0(transitive)
+ Addedcss-select@1.2.0(transitive)
+ Addedcss-what@2.1.3(transitive)
+ Addeddomhandler@2.4.2(transitive)
+ Addedduplexer3@0.1.5(transitive)
+ Addedget-stream@3.0.0(transitive)
+ Addedgot@6.7.1(transitive)
+ Addedhtmlparser2@3.10.1(transitive)
+ Addediconv-lite@0.4.15(transitive)
+ Addedio-cep@2.2.1(transitive)
+ Addedlodash.assignin@4.2.0(transitive)
+ Addedlodash.bind@4.2.1(transitive)
+ Addedlodash.defaults@4.2.0(transitive)
+ Addedlodash.filter@4.6.0(transitive)
+ Addedlodash.flatten@4.4.0(transitive)
+ Addedlodash.foreach@4.5.0(transitive)
+ Addedlodash.map@4.6.0(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedlodash.pick@4.4.0(transitive)
+ Addedlodash.reduce@4.6.0(transitive)
+ Addedlodash.reject@4.6.0(transitive)
+ Addedlodash.some@4.6.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedslug@0.9.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedtimed-out@4.0.1(transitive)
+ Addedunicode@14.0.0(transitive)
+ Addedunzip-response@2.0.1(transitive)
- Removedcheerio@0.19.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedcss-select@1.0.0(transitive)
- Removedcss-what@1.0.0(transitive)
- Removeddomhandler@2.3.0(transitive)
- Removeddomutils@1.4.3(transitive)
- Removedduplexer2@0.1.4(transitive)
- Removedentities@1.0.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedgot@5.7.1(transitive)
- Removedhtmlparser2@3.8.3(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedio-cep@0.5.3(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedisarray@0.0.11.0.0(transitive)
- Removedlodash@3.10.1(transitive)
- Removednode-status-codes@1.0.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedread-all-stream@3.1.0(transitive)
- Removedreadable-stream@1.1.142.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedstring_decoder@0.10.311.1.1(transitive)
- Removedtimed-out@3.1.3(transitive)
- Removedunzip-response@1.0.2(transitive)
Updatedio-cep@^2.1.1