Merge pull request #21 from 67P/features/cli-repl

Make the CLI a real REPL
This commit is contained in:
fsmanuel 2018-04-10 13:54:33 +02:00 committed by GitHub
commit 7f4a26108c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,5 @@
const REPL = require('repl');
module.exports = function(callback) {
const Registry = artifacts.require('./Registry.sol');
Registry.deployed().then(async (registry) => {
@ -26,7 +28,17 @@ module.exports = function(callback) {
console.log("\nResult:");
console.log(result);
callback();
console.log("\nStartig a REPL. (type .exit to exit)");
console.log(`defined variables: result, ${contractName}, web3`);
let r = REPL.start();
r.context.result = result;
r.context[contractName] = contract;
r.context.web3 = web3;
r.on('exit', () => {
console.log('Bye');
callback();
})
}).catch((error) => {
console.log("Call failed. Probably the contract raised an error?\n");
console.log("...");