UNPKG

@brasil-interface/cli

Version:
89 lines 5.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const input_helper_1 = require("../../helpers/input-helper"); const output_helper_1 = require("../../helpers/output-helper"); const sdks_1 = require("@brasil-interface/sdks"); const commander_1 = require("commander"); const cepAberto = commander_1.program .command("cep-aberto") .description("CepAbertoAPI utilities."); cepAberto .command("get-by-number <cep>") .description("PT-BR: Obtém informações de endereço pelo número do CEP. EN-US: Get address information by CEP number.") .option("-t, --token <token>", "PT-BR: O token de acesso à API do CepAberto. EN-US: The access token to the CepAberto API.") .option("-o, --output <filepath>", "PT-BR: Caminho do arquivo de output. EN-US: Output file path") .option("-c, --copy", "PT-BR: Copia o resultado para a área de transferência. EN-US: Copy the result to the clipboard.") .action(async (cep, options) => { const { token, output, copy } = options; const cepAbertoAPI = new sdks_1.CepAbertoAPI(token); const result = await cepAbertoAPI.getCepByNumber(cep); output_helper_1.OutputHelper.handleResultOutputBasedOnOptions(result, { output, copyToClipboard: copy, }); }); cepAberto .command("get-by-coordinates <lat> <lng>") .description("PT-BR: Obtém informações de endereço pelas coordenadas de latitude e longitude. EN-US: Get address information by latitude and longitude coordinates.") .option("-t, --token <token>", "PT-BR: O token de acesso à API do CepAberto. EN-US: The access token to the CepAberto API.") .option("-o, --output <filepath>", "PT-BR: Caminho do arquivo de output. EN-US: Output file path") .option("-c, --copy", "PT-BR: Copia o resultado para a área de transferência. EN-US: Copy the result to the clipboard.") .action(async (lat, lng, options) => { const { token, output, copy } = options; const cepAbertoAPI = new sdks_1.CepAbertoAPI(token); const result = await cepAbertoAPI.getCepByCoordinates(lat, lng); output_helper_1.OutputHelper.handleResultOutputBasedOnOptions(result, { output, copyToClipboard: copy, }); }); cepAberto .command("get-by-address <state> <city> [street] [neighborhood]") .description("PT-BR: Obtém informações de endereço pelo estado, cidade, rua e bairro. EN-US: Get address information by state, city, street and neighborhood.") .option("-t, --token <token>", "PT-BR: O token de acesso à API do CepAberto. EN-US: The access token to the CepAberto API.") .option("-o, --output <filepath>", "PT-BR: Caminho do arquivo de output. EN-US: Output file path") .option("-c, --copy", "PT-BR: Copia o resultado para a área de transferência. EN-US: Copy the result to the clipboard.") .action(async (state, city, street, neighborhood, options) => { const { token, output, copy } = options; const cepAbertoAPI = new sdks_1.CepAbertoAPI(token); const result = await cepAbertoAPI.getCepByAddress(state, city, street, neighborhood); output_helper_1.OutputHelper.handleResultOutputBasedOnOptions(result, { output, copyToClipboard: copy, }); }); cepAberto .command("get-cities-by-state <state>") .description("PT-BR: Obtém uma lista de cidades em um determinado estado. EN-US: Get a list of cities in a given state.") .option("-t, --token <token>", "PT-BR: O token de acesso à API do CepAberto. EN-US: The access token to the CepAberto API.") .option("-o, --output <filepath>", "PT-BR: Caminho do arquivo de output. EN-US: Output file path") .option("-c, --copy", "PT-BR: Copia o resultado para a área de transferência. EN-US: Copy the result to the clipboard.") .action(async (state, options) => { const { token, output, copy } = options; const cepAbertoAPI = new sdks_1.CepAbertoAPI(token); const result = await cepAbertoAPI.getCitiesByState(state); output_helper_1.OutputHelper.handleResultOutputBasedOnOptions(result, { output, copyToClipboard: copy, }); }); cepAberto .command("update-ceps <cepList>") .description("PT-BR: Atualiza uma lista de números de CEP. EN-US: Update a list of CEP numbers.") .option("-t, --token <token>", "PT-BR: O token de acesso à API do CepAberto. EN-US: The access token to the CepAberto API.") .option("-i, --input <filepath>", "PT-BR: Caminho do arquivo de input. EN-US: Input file path") .option("-o, --output <filepath>", "PT-BR: Caminho do arquivo de output. EN-US: Output file path") .option("-c, --copy", "PT-BR: Copia o resultado para a área de transferência. EN-US: Copy the result to the clipboard.") .action(async (cepList, options) => { const { token, input, output, copy } = options; const cepAbertoAPI = new sdks_1.CepAbertoAPI(token); const cepArray = input_helper_1.InputHelper.getArrayFromInputAlternativesOrFail(cepList, { input, }); const result = await cepAbertoAPI.updateCeps(cepArray); output_helper_1.OutputHelper.handleResultOutputBasedOnOptions(result, { output, copyToClipboard: copy, }); }); //# sourceMappingURL=cep-aberto.js.map