Skip to content

Commit cd13ffe

Browse files
committed
added build script for windows build
added command line options for daemon and walletd connection parameters
1 parent 4d283d7 commit cd13ffe

File tree

4 files changed

+1217
-3
lines changed

4 files changed

+1217
-3
lines changed

build.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import caxa from "caxa";
2+
3+
(async () => {
4+
await caxa({
5+
input: ".",
6+
output: "conceal-cli.exe",
7+
command: [
8+
"{{caxa}}/node_modules/.bin/node",
9+
"{{caxa}}/index.js"
10+
],
11+
});
12+
})();

index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Command } from 'commander';
22
import { fileURLToPath } from 'url';
3+
import { hideBin } from 'yargs/helpers';
4+
import yargs from 'yargs/yargs';
35
import inquirer from 'inquirer';
46
import ccx from 'conceal-api';
57
import path from 'path';
@@ -18,18 +20,36 @@ let config = {
1820
timeout: 5000
1921
}
2022

23+
2124
// check if we have config.json present in same dir
2225
if (fs.existsSync(path.join(__dirname, 'config.json'))) {
2326
config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json'), 'utf8'));
2427
}
2528

29+
// parse arguments and options
30+
const argv = yargs(hideBin(process.argv)).argv
31+
32+
if (argv.dh) { config.daemonHost = argv.dh; }
33+
if (argv.dp) { config.daemonRpcPort = argv.dp; }
34+
if (argv.wh) { config.walletHost = argv.wh; }
35+
if (argv.wp) { config.walletRpcPort = argv.wp; }
36+
37+
if (argv.daemonHost) { config.daemonHost = argv.daemonHost; }
38+
if (argv.daemonPort) { config.daemonRpcPort = argv.daemonPort; }
39+
if (argv.walletdHost) { config.daemonHost = argv.walletdHost; }
40+
if (argv.walletdPort) { config.walletRpcPort = argv.walletdPort; }
41+
2642
// create the api with the config
2743
const ccxApi = new ccx(config);
2844

2945
// creating tool
3046
program
3147
.name("conceal-api-demo")
3248
.description("A CLI demo for conceal api")
49+
.option('--dh, --daemon-host <type>', 'Daemon Host (URL)')
50+
.option('--dp, --daemon-port <type>', 'Daemon Port (Number)')
51+
.option('--wh, --walletd-host <type>', 'Walletd Host (URL)')
52+
.option('--wp, --walletd-port <type>', 'Walletd Host (Number)')
3353
.version("1.0.0");
3454

3555
// ****************************************************
@@ -899,4 +919,4 @@ daemon
899919
});
900920

901921

902-
program.parse();
922+
program.parse(process.argv);

0 commit comments

Comments
 (0)