From ca91e89ef9e1a45cd9649def52c6eeb39e53980c Mon Sep 17 00:00:00 2001 From: Andrey Nedobylsky Date: Wed, 19 Feb 2020 14:44:49 +0300 Subject: [PATCH] Config write func --- main.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/main.js b/main.js index 4bd6822..d31e998 100644 --- a/main.js +++ b/main.js @@ -32,6 +32,7 @@ program .option('--clear', 'Clear all saved chain and deletes wallet. WARNING: You can lose important data') .option('--clear-db', 'Clear all saved chain and calculated wallets.') .option('-c, --config [path]', 'Core config path', 'config.json') + .option('--write-config [path]', 'Save config in [path] file', false) .option('--work-dir [path]', 'Working directory', false) .option('--keyring-emission', 'Generate and deploy keyring', false) .option('--generate-wallets [keyring path]', 'Generate wallets from keyring file', false) @@ -170,14 +171,17 @@ try { } } - - /* try { - fs.writeFileSync('config.json', JSON.stringify(config)); - } catch (e) { - console.log('Info: Can\'t save config'); - }*/ } catch (e) { - logger.info('No configure found. Using standard configuration.'); + logger.warning('No configure found. Using standard configuration.'); +} + + +if(program.writeConfig) { + try { + fs.writeFileSync(program.writeConfig, JSON.stringify(config)); + } catch (e) { + logger.warning('Can\'t save config'); + } } config.program = program;