Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cli options to specify starting chains #103

Open
npty opened this issue Mar 24, 2023 · 0 comments
Open

Allow cli options to specify starting chains #103

npty opened this issue Mar 24, 2023 · 0 comments

Comments

@npty
Copy link
Member

npty commented Mar 24, 2023

When running npm run start on our CLI, the default chains are launched. However, I would like to add options to allow users to specify which chains to launch at startup.

I propose adding options to specify the desired chains using a comma-separated list. For example:

npm run start --chains evm:avalanche,moonbeam --chains move:aptos,sui

This command would start the EVM chains on Avalanche and Moonbeam, and the Move chains on Aptos and SUI.

I believe that this feature would greatly enhance the flexibility and customization options to running our examples, and would be a valuable addition for our users.

Here's an example script to parse the example command above:

const { program } = require("commander");

function collect(value, previous) {
  return previous.concat([value]);
}

program
  .option(
    "--chains <chains>",
    "comma-separated list of chains to start",
    collect,
    []
  )
  .parse();

const options = program.opts();

const chains = options.chains.reduce((acc, chain) => {
  const [protocol, names] = chain.split(":");
  const chainNames = names.split(",");
  return {
    ...acc,
    [protocol]: chainNames,
  };
}, {});

console.log(chains);

Output

{ evm: [ 'avalanche', 'moonbeam' ], move: [ 'aptos', 'sui' ] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant