-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (36 loc) · 1.46 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// index.js
const { Command } = require('commander');
const callCommand = require('./lib/call');
const { setConfigCommand, viewConfigCommand } = require('./lib/configCommands');
const program = new Command();
program
.name('orbit')
.description('A CLI tool to call contract methods across multiple blockchains.')
.version('1.0.0');
// index.js
program
.command('call <contract_name>')
.description('Call a method on a smart contract.')
.requiredOption('-m, --method <method_name>', 'Method name to invoke')
.requiredOption('-p, --params <params>', 'Method parameters in JSON format')
.requiredOption('-c, --chain <chain>', 'Blockchain to interact with')
.option('-s, --sender <keypair_file_path>', 'Path to the sender\'s Solana keypair file')
.option('-u, --url <url>', 'URL of the target blockchain')
.option('-e, --env <environment>', 'Environment (mainnet/testnet)', 'testnet')
.option('--sub-chain <sub_chain>', 'Sub-chain for EVM chains (e.g., avalanche, polygon)')
.action(callCommand);
program
.command('config')
.description('Configure the CLI tool')
.option('-s, --set <key=value>', 'Set a configuration value')
.option('-v, --view', 'View current configurations')
.action((options) => {
if (options.set) {
setConfigCommand(options.set);
} else if (options.view) {
viewConfigCommand();
} else {
console.log('Please specify an option. Use --help for more information.');
}
});
program.parse(process.argv);