MCPcopy Create free account
hub / github.com/subquery/subql / yargsBuilder

Function yargsBuilder

packages/node-core/src/yargs.ts:33–392  ·  view source on GitHub ↗
(options: YargsOptions<RootO, RunO>)

Source from the content-addressed store, hash-verified

31// Unable to properly type this, TS seems to resolve the correct type already
32// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
33export function yargsBuilder<
34 RootO extends Record<string, yargs.Options> = Record<string, never>,
35 RunO extends Record<string, yargs.Options> = Record<string, never>,
36>(options: YargsOptions<RootO, RunO>) {
37 return (
38 yargs(hideBin(process.argv))
39 .env('SUBQL_NODE')
40 .command({
41 command: 'test',
42 describe: 'Run tests for a SubQuery application',
43 builder: {},
44 handler: (argv) => {
45 initLogger(argv.debug as string, argv.outputFmt as 'json' | 'colored', argv.logLevel as string | undefined);
46 return options.initTesting();
47 },
48 })
49 .command({
50 command: 'force-clean',
51 describe:
52 'Clean the database dropping project schemas and tables. Once the command is executed, the application would exit upon completion.',
53 builder: {},
54 handler: (argv) => {
55 initLogger(argv.debug as string, argv.outputFmt as 'json' | 'colored', argv.logLevel as string | undefined);
56
57 return options.initForceClean();
58 },
59 })
60 .command({
61 command: 'reindex',
62 describe:
63 'Reindex to specified block height. Historical must be enabled for the targeted project (--historical). The application will exit upon completion.',
64 builder: (yargs) =>
65 yargs.options('targetHeight', {
66 type: 'number',
67 description: 'set targetHeight',
68 require: true,
69 }),
70 handler: (argv) => {
71 initLogger(argv.debug as string, argv.outputFmt as 'json' | 'colored', argv.logLevel as string | undefined);
72 return options.initReindex(argv.targetHeight);
73 },
74 })
75 // Note we must have default command $0 at last to avoid override
76 .command({
77 command: '$0', //default command
78 describe: 'Index a SubQuery application',
79 builder: (yargs) =>
80 yargs
81 .options({
82 ...options.runOptions,
83 'batch-size': {
84 demandOption: false,
85 describe: 'Batch size of blocks to fetch in one round',
86 type: 'number',
87 },
88 'dictionary-timeout': {
89 demandOption: false,
90 describe: 'Max timeout for dictionary query',

Callers 1

yargs.tsFile · 0.90

Calls 1

initLoggerFunction · 0.90

Tested by

no test coverage detected