-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I'm thinking we should transition away from Hardhat tasks for example-specific functionality to commands.
Basically, right now the Swap example has a Swap task. It doesn't make sense to make it a part of the CLI, because it's only used in that example. We have a Hardhat task for it. There are several problems:
- We have both CLI and Hardhat tasks, experience is very inconsistent.
- Project specific tasks are not always EVM, so using Hardhat for them is confusing.
Instead, what we can do is migrate all these tasks to Commander.js commands.
Let's say the Swap example has a "deploy" command.
swap/commands/deploy.ts:
import { Command } from "commander";
export default function registerDeploy(program: Command) {
program
.command("deploy")
.description("Deploy swap contract")
.action(() => {
console.log("Deploying swap...");
});
}swap/commands/index.ts:
#!/usr/bin/env node
import { Command } from "commander";
import deploy from "./deploy.js";
const program = new Command();
deploy(program);
program.parse(process.argv);A user will be able to execute deploy from the console (which doesn't even require ZetaChain CLI):
ts-node ./commands/index.ts deploy
And all commands from commands/ dir will be mounted to ZetaChain CLI, so you'd be able to call deploy from the CLI:
npx zetachain commands deploy
Best of both worlds.
hernan-clich
Metadata
Metadata
Assignees
Labels
No labels