From b3d19e556c662766b300bd917d7737c4a4b7e778 Mon Sep 17 00:00:00 2001 From: bumi Date: Mon, 9 Apr 2018 01:52:51 +0200 Subject: [PATCH] Make the CLI a real reply After calling the contract function a reply is started. This allows to interact and inspect the result object or call more functions on the contract. --- scripts/cli.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/cli.js b/scripts/cli.js index c617354..20ac150 100644 --- a/scripts/cli.js +++ b/scripts/cli.js @@ -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("...");