Skip to content

Commit

Permalink
cli.js minor edit
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Apr 7, 2020
1 parent 3494fd4 commit c6a1ab6
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions examples/js/cli.js
Expand Up @@ -209,8 +209,7 @@ const printHumanReadable = (exchange, result) => {

async function main () {

const requirements = exchangeId && methodName
if (!requirements) {
if (!exchangeId) {

printUsage ()

Expand Down Expand Up @@ -261,47 +260,54 @@ async function main () {
}
}

if (typeof exchange[methodName] === 'function') {
if (methodName) {

log (exchange.id + '.' + methodName, '(' + args.join (', ') + ')')
if (typeof exchange[methodName] === 'function') {

while (true) {
log (exchange.id + '.' + methodName, '(' + args.join (', ') + ')')

try {
while (true) {

const result = await exchange[methodName] (... args)
printHumanReadable (exchange, result)
try {

} catch (e) {
const result = await exchange[methodName] (... args)
printHumanReadable (exchange, result)

if (e instanceof ExchangeError) {
} catch (e) {

log.red (e.constructor.name, e.message)
if (e instanceof ExchangeError) {

} else if (e instanceof NetworkError) {
log.red (e.constructor.name, e.message)

log.yellow (e.constructor.name, e.message)
} else if (e instanceof NetworkError) {

}
log.yellow (e.constructor.name, e.message)

}

log.dim ('---------------------------------------------------')
log.dim ('---------------------------------------------------')

// rethrow for call-stack // other errors
throw e
// rethrow for call-stack // other errors
throw e

}

if (!poll)
break;
}

if (!poll)
break;
}
} else if (exchange[methodName] === undefined) {

log.red (exchange.id + '.' + methodName + ': no such property')

} else if (exchange[methodName] === undefined) {
} else {

log.red (exchange.id + '.' + methodName + ': no such property')
printHumanReadable (exchange, exchange[methodName])
}

} else {

printHumanReadable (exchange, exchange[methodName])
console.log (exchange)
}
}
}
Expand Down

0 comments on commit c6a1ab6

Please sign in to comment.