From de6ba9df559174e381665c09b72e6ea1d6a600b9 Mon Sep 17 00:00:00 2001 From: benpreiser Date: Sat, 22 Oct 2022 15:39:58 -0400 Subject: [PATCH] chore: move command line parsing logic to main file scope --- scripts/build-durable-nonce.js | 43 ++++++++++++++++------------------ 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/scripts/build-durable-nonce.js b/scripts/build-durable-nonce.js index 3a885134..e031e0a2 100644 --- a/scripts/build-durable-nonce.js +++ b/scripts/build-durable-nonce.js @@ -3,6 +3,26 @@ const { binary_to_base58, base58_to_binary } = require('base58-js'); const { createInterface } = require('readline'); const { program, Option } = require('commander'); +program + .command('create') + .description('create a new solana keypair') + .showHelpAfterError() + .action(handleCreate); + +program + .command('import') + .description('import an existing solana keypair') + .showHelpAfterError() + .addOption( + new Option( + '-n, --network ', + 'network for nonce account creation' + ) + .choices(['devnet', 'mainnet-beta']) + .makeOptionMandatory() + ) + .action(handleImport); + const readline = createInterface({ input: process.stdin, output: process.stdout, @@ -83,30 +103,7 @@ function handleCreate() { ); } -function defineCommands() { - program - .command('create') - .description('create a new solana keypair') - .showHelpAfterError() - .action(handleCreate); - - program - .command('import') - .description('import an existing solana keypair') - .showHelpAfterError() - .addOption( - new Option( - '-n, --network ', - 'network for nonce account creation' - ) - .choices(['devnet', 'mainnet-beta']) - .makeOptionMandatory() - ) - .action(handleImport); -} - async function main() { - defineCommands(); await program.parseAsync(process.argv); process.exit(0); }