Skip to content

Commit

Permalink
feature(logger) Proper logger support and error reporting in CLI
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <[email protected]>
  • Loading branch information
jeromesimeon committed Oct 4, 2019
1 parent e5af6a7 commit bec5082
Show file tree
Hide file tree
Showing 15 changed files with 1,378 additions and 32 deletions.
653 changes: 647 additions & 6 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions packages/concerto-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

'use strict';


const Logger = require('@accordproject/concerto-core').Logger;
const Commands = require('./lib/commands');

require('yargs')
Expand All @@ -35,15 +35,15 @@ require('yargs')
});
}, (argv) => {
if (argv.verbose) {
console.log(`validate sample in ${argv.format} against the models ${argv.ctoFiles}`);
Logger.info(`validate sample in ${argv.format} against the models ${argv.ctoFiles}`);
}

return Commands.validate(argv.sample, argv.ctoFiles)
.then((result) => {
console.log(result);
Logger.info(result);
})
.catch((err) => {
console.log(err.message + ' ' + err);
Logger.error(err.message);
});
})
.command('generate', 'generate code from model files', (yargs) => {
Expand All @@ -65,15 +65,15 @@ require('yargs')
});
}, (argv) => {
if (argv.verbose) {
console.log(`generate code in format ${argv.format} from the models ${argv.ctoFiles} into directory ${argv.outputDirectory}`);
Logger.info(`generate code in format ${argv.format} from the models ${argv.ctoFiles} into directory ${argv.outputDirectory}`);
}

return Commands.generate(argv.format, argv.ctoFiles, argv.outputDirectory)
.then((result) => {
console.log(result);
Logger.info(result);
})
.catch((err) => {
console.log(err.message + ' ' + err);
Logger.error(err.message);
});
})
.command('get', 'save local copies of external model dependencies', (yargs) => {
Expand All @@ -90,12 +90,12 @@ require('yargs')
});
}, (argv) => {
if (argv.verbose) {
console.log(`Saving external models from ${argv.ctoFiles} into directory: ${argv.outputDirectory}`);
Logger.info(`Saving external models from ${argv.ctoFiles} into directory: ${argv.outputDirectory}`);
}

return Commands.getExternalModels(argv.ctoFiles, argv.outputDirectory)
.catch((err) => {
console.log(err.message + ' ' + err);
Logger.error(err.message);
});
})
.option('verbose', {
Expand Down
221 changes: 221 additions & 0 deletions packages/concerto-cli/test/models/parseerror.cto
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
namespace org.accordproject.money

/**
* Represents an amount of Cryptocurrency
*/
concept CryptoMonetaryAmount {
o Double doubleValue
o CryptoCurrencyCode cryptoCurrencyCode
//} Error here

/**
* Cyptocurrency codes. From https://en.wikipedia.org/wiki/List_of_cryptocurrencies
*/
enum CryptoCurrencyCode {
o ADA
o BCH
o BTC
o DASH
o EOS
o ETC
o ETH
o LTC
o NEO
o XLM
o XMR
o XRP
o ZEC
}

/**
* Represents an amount of money
*/
concept MonetaryAmount {
o Double doubleValue // convert to fixed-point?
o CurrencyCode currencyCode
}

/**
* ISO 4217 codes. From https://en.wikipedia.org/wiki/ISO_4217
* https://www.currency-iso.org/en/home/tables/table-a1.html
*/
enum CurrencyCode {
o AED
o AFN
o ALL
o AMD
o ANG
o AOA
o ARS
o AUD
o AWG
o AZN
o BAM
o BBD
o BDT
o BGN
o BHD
o BIF
o BMD
o BND
o BOB
o BOV
o BRL
o BSD
o BTN
o BWP
o BYN
o BZD
o CAD
o CDF
o CHE
o CHF
o CHW
o CLF
o CLP
o CNY
o COP
o COU
o CRC
o CUC
o CUP
o CVE
o CZK
o DJF
o DKK
o DOP
o DZD
o EGP
o ERN
o ETB
o EUR
o FJD
o FKP
o GBP
o GEL
o GHS
o GIP
o GMD
o GNF
o GTQ
o GYD
o HKD
o HNL
o HRK
o HTG
o HUF
o IDR
o ILS
o INR
o IQD
o IRR
o ISK
o JMD
o JOD
o JPY
o KES
o KGS
o KHR
o KMF
o KPW
o KRW
o KWD
o KYD
o KZT
o LAK
o LBP
o LKR
o LRD
o LSL
o LYD
o MAD
o MDL
o MGA
o MKD
o MMK
o MNT
o MOP
o MRU
o MUR
o MVR
o MWK
o MXN
o MXV
o MYR
o MZN
o NAD
o NGN
o NIO
o NOK
o NPR
o NZD
o OMR
o PAB
o PEN
o PGK
o PHP
o PKR
o PLN
o PYG
o QAR
o RON
o RSD
o RUB
o RWF
o SAR
o SBD
o SCR
o SDG
o SEK
o SGD
o SHP
o SLL
o SOS
o SRD
o SSP
o STN
o SVC
o SYP
o SZL
o THB
o TJS
o TMT
o TND
o TOP
o TRY
o TTD
o TWD
o TZS
o UAH
o UGX
o USD
o USN
o UYI
o UYU
o UZS
o VEF
o VND
o VUV
o WST
o XAF
o XAG
o XAU
o XBA
o XBB
o XBC
o XBD
o XCD
o XDR
o XOF
o XPD
o XPF
o XPT
o XSU
o XTS
o XUA
o XXX
o YER
o ZAR
o ZMW
o ZWL
}
Loading

0 comments on commit bec5082

Please sign in to comment.