Skip to content

Commit

Permalink
opt command
Browse files Browse the repository at this point in the history
  • Loading branch information
jiguantong committed Oct 30, 2024
1 parent 8c17639 commit 026bb0b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/publisher-client/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';

import { Command } from 'commander';
import { Command, Option } from 'commander';
import { Container } from 'typedi';
import { PublisherStarter } from './command/start';
import { logger } from "@ringdao/xapi-common";
Expand All @@ -15,17 +15,23 @@ program
program
.command("start")
.description("start XAPI Publisher")
.requiredOption(
"--near-account <char>",
.addOption(new Option(
"--near-account <string>",
"near account",
process.env["XAPI_NEAR_ACCOUNT"],
)
.requiredOption(
"--near-private-key <char>",
).env("XAPI_NEAR_ACCOUNT"))
.addOption(new Option(
"--near-private-key <string>",
"near private key",
process.env["XAPI_NEAR_PRIVATE_KEY"],
)
).env("XAPI_NEAR_PRIVATE_KEY"))
.action(async (options) => {
if (!options.nearAccount) {
logger.error('missing near account, please add --near-account or set env.XAPI_NEAR_ACCOUNT');
process.exit(1);
}
if (!options.nearPrivateKey) {
logger.error('missing near private key, please add --near-private-key or set env.XAPI_NEAR_PRIVATE_KEY');
process.exit(1);
}
const c = Container.get(PublisherStarter);
await c.start({
nearAccount: options.nearAccount,
Expand Down

0 comments on commit 026bb0b

Please sign in to comment.