Replace empty logs and name escape sequence

This commit is contained in:
Rafael Taranto 2019-06-03 10:19:58 -03:00 committed by Josh Harvey
parent fb2095e444
commit a930d8b647

View file

@ -13,18 +13,14 @@ const rl = readline.createInterface({
const sql = `select regexp_replace(crypto_code, '$', ' ') as code,regexp_replace(address, '^', ' ') as address from blacklist` const sql = `select regexp_replace(crypto_code, '$', ' ') as code,regexp_replace(address, '^', ' ') as address from blacklist`
const insertSql = `insert into blacklist(crypto_code, address) values ($1, $2)` const insertSql = `insert into blacklist(crypto_code, address) values ($1, $2)`
const makeDimAndReset = '\x1b[2m%s\x1b[0m'
db.query(sql) db.query(sql)
.then(many => { .then(many => {
console.log('') console.log(os.EOL, 'Here is your current list of prohibited addresses:', os.EOL)
console.log('Here is your current list of prohibited addresses:') console.log(many.map(it => `${it.code} | ${it.address}`).join(os.EOL), os.EOL)
console.log('') console.log('What address would you like to add to the list?', os.EOL)
console.log(many.map(it => `${it.code} | ${it.address}`).join(os.EOL)) console.log(makeDimAndReset, 'Example:', 'bc1q8pu2zlfxg8jf4cyuf844rl3uxmmw8sj9yaa393', os.EOL)
console.log('')
console.log('What address would you like to add to the list?')
console.log('')
console.log('\x1b[2m%s\x1b[0m', 'Example:', 'bc1q8pu2zlfxg8jf4cyuf844rl3uxmmw8sj9yaa393')
console.log('')
rl.question('Address: ', (address) => { rl.question('Address: ', (address) => {
var aphaNumericRegex = /^([0-9]|[a-z])+([0-9a-z]+)$/i var aphaNumericRegex = /^([0-9]|[a-z])+([0-9a-z]+)$/i
@ -32,11 +28,8 @@ db.query(sql)
return errorHandler(new Error('Invalid address')) return errorHandler(new Error('Invalid address'))
} }
console.log('') console.log(os.EOL, 'What is the ticker symbol of the coin that this address belongs to?', os.EOL)
console.log('What is the ticker symbol of the coin that this address belongs to?') console.log(makeDimAndReset, 'Example:', 'BTC', os.EOL)
console.log('')
console.log('\x1b[2m%s\x1b[0m', 'Example:', 'BTC')
console.log('')
rl.question('Ticker symbol: ', (cryptoCode) => { rl.question('Ticker symbol: ', (cryptoCode) => {
try { try {
@ -45,13 +38,10 @@ db.query(sql)
errorHandler(err) errorHandler(err)
} }
console.log('')
db.none(insertSql, [cryptoCode, address]) db.none(insertSql, [cryptoCode, address])
.then(() => db.query(sql)) .then(() => db.query(sql))
.then(many2 => { .then(many2 => {
console.log(`Address added. Here's the new list of prohibited addresses:`) console.log(os.EOL, `Address added. Here's the new list of prohibited addresses:`, os.EOL)
console.log('')
console.log(many2.map(it => `${it.code} | ${it.address}`).join(os.EOL)) console.log(many2.map(it => `${it.code} | ${it.address}`).join(os.EOL))
rl.close() rl.close()
process.exit(0) process.exit(0)