diff --git a/remix-simulator/bin/ethsim b/remix-simulator/bin/ethsim index e819929748..20aea678cb 100755 --- a/remix-simulator/bin/ethsim +++ b/remix-simulator/bin/ethsim @@ -1,6 +1,29 @@ #!/usr/bin/env node -const Server = require('../src/server'); +const program = require('commander') +const version = require('../package.json').version + +program + .command('version') + .description("outputs version number") + .action(() => { + console.log(version) + process.exit(0) + }) + +program + .command('help') + .description("outputs usage information") + .action(() => { + program.help() + process.exit(0) + }) + +program + .option('-p, --port [port]', 'specify port') + .parse(process.argv) + +const Server = require('../src/server') const server = new Server() -server.start() +server.start(program.port || 8545) diff --git a/remix-simulator/package.json b/remix-simulator/package.json index ad25583866..975ea75fb4 100644 --- a/remix-simulator/package.json +++ b/remix-simulator/package.json @@ -17,6 +17,7 @@ "ansi-gray": "^0.1.1", "body-parser": "^1.18.2", "color-support": "^1.1.3", + "commander": "^2.19.0", "express": "^4.16.3", "express-ws": "^4.0.0", "fast-async": "^6.3.7", diff --git a/remix-simulator/src/server.js b/remix-simulator/src/server.js index ab18a5e9be..1f4c1753e4 100644 --- a/remix-simulator/src/server.js +++ b/remix-simulator/src/server.js @@ -11,7 +11,7 @@ class Server { this.provider = new Provider() } - start(host, port) { + start(port) { expressWs(app) app.use(bodyParser.urlencoded({extended: true})) @@ -41,7 +41,7 @@ class Server { }) }) - app.listen(8545, () => log('Remix Simulator listening on port 8545!')) + app.listen(port, () => log('Remix Simulator listening on port ' + port)) } }