commander#program TypeScript Examples

The following examples show how to use commander#program. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts    From anchorcli with Apache License 2.0 6 votes vote down vote up
export function run(argv: string[]): void {
  try {
    program
      .name('anchorcli')
      .version('0.0.1')
      .option('-v,--verbose', 'Show verbose error logs')
      .description(
        'Command-line interface for interacting with Anchor Protocol on Terra',
      );
    _.each(commands, (command: Command) => {
      program.addCommand(command);
    });
    program.parse(argv);
  } catch (e) {
    logger.error(e.message);
  }
}
Example #2
Source File: cli.ts    From xwind with MIT License 6 votes vote down vote up
async function main() {
  await program
    .version(VERSION)
    .option(
      "-c, --config <path>",
      "path to tailwind.config.js",
      "./tailwind.config.js"
    )
    .option("-w, --watch", "watch files", false)
    .parseAsync(process.argv);

  await run(program);
}
Example #3
Source File: bin.ts    From gengen with MIT License 6 votes vote down vote up
program
    .command('generate')
    .alias('g')
    .option('--aliasName <string>')
    .option('--file <string>')
    .option('--url <string>')
    .option('--output <string>')
    .option('--configOutput <string>')
    .option('--all')
    .option('--withRequestOptions')
    .description('Generates models and services')
    .action(async (params) => {
        const options = getOptions(params);
        const spec = await getOpenAPISpec(options);
        const codeGen = new GenGenCodeGen(options, spec);
        await codeGen.run();
    });
Example #4
Source File: cli.ts    From deskbluez with MIT License 6 votes vote down vote up
private preAction = async () => {
        this.profile = program.profile || "default";
        this.adapter = program.adapter || "hci0";

        if (program.debug) logger.setLevel(logger.LEVEL.DEBUG);

        this.config = new ConfigManager(this.profile);

        await this.bluetooth.init(this.adapter);
    }
Example #5
Source File: cli_command.ts    From ardrive-cli with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
	 * @param {CommandDescriptor} commandDescription an immutable representation of a command
	 * @param {string[]} argv a custom argv for testing purposes
	 */
	constructor(readonly commandDescription: CommandDescriptor, program: CliApiObject = programApi) {
		program.name('ardrive');
		program.addHelpCommand(true);
		program.usage('[command] [command-specific options]');
		// Override the commander's default exit (process.exit()) to avoid abruptly interrupting the script execution
		program.exitOverride();
		setCommanderCommand(this.commandDescription, program);
		CLICommand.allCommandInstances.push(this);
	}
Example #6
Source File: index.ts    From backstage with Apache License 2.0 6 votes vote down vote up
main = (argv: string[]) => {
  program.name('backstage-cli').version(version);

  registerCommands(program);

  program.on('command:*', () => {
    console.log();
    console.log(chalk.red(`Invalid command: ${program.args.join(' ')}`));
    console.log();
    program.outputHelp();
    process.exit(1);
  });

  program.parse(argv);
}
Example #7
Source File: index.ts    From tzklar-boilerplate with MIT License 6 votes vote down vote up
program.parseAsync().catch((error) => {
  if (typeof error === "string") console.log(kleur.red(error));
  else if (error instanceof TezosOperationError) {
    console.log(kleur.red(`Tezos operation error: ${kleur.bold(error.message)}`));
  } else {
    console.log(kleur.red("unknown error:"));
    console.log(error);
  }
});
Example #8
Source File: auction-house-cli.ts    From metaplex with Apache License 2.0 6 votes vote down vote up
function programCommand(name: string) {
  return program
    .command(name)
    .option(
      '-e, --env <string>',
      'Solana cluster env name, i.e. mainnet-beta, testnet, devnet',
      'devnet', //mainnet-beta, testnet, devnet
    )
    .option(
      '-k, --keypair <path>',
      `Solana wallet location`,
      '--keypair not provided',
    )
    .option('-l, --log-level <string>', 'log level', setLogLevel);
}
Example #9
Source File: cmd.ts    From cross-seed with Apache License 2.0 6 votes vote down vote up
program
	.command("gen-config")
	.description("Generate a config file")
	.option(
		"-d, --docker",
		"Generate the docker config instead of the normal one"
	)
	.action((options) => {
		generateConfig(options);
	});
Example #10
Source File: index.ts    From nota with MIT License 6 votes vote down vote up
commonOpts(program.command("edit"))
  .option("-p, --port <port>", "Port to run local server", parseInt)
  .option("-s, --static <dir>", "Directory to serve static files")
  .action(
    async (file, { config, ...opts }) =>
      await server.main({
        file,
        config: await loadConfig(config),
        ...opts,
      })
  );
Example #11
Source File: tzgen.ts    From nft-tutorial with MIT License 6 votes vote down vote up
//prettier-ignore
program
  .command('init')
  .alias('i')
  .description('create tzgen.json file with the generator environment settings')
  .option('-l --ligo <ligo_dir>', 'ligo code directory. The default is ./ligo')
  .option('-o --compile-out <out_dir>', 'contract compilation output directory. The default is ./ligo/out')
  .option('-t --ts <ts_dir>', 'TypeScript source directory. The default is ./src')
  .action(async options => initConfig(options.ligo, options.compileOut, options.ts));
Example #12
Source File: make-monthly-stat.ts    From merged-pr-stat with MIT License 6 votes vote down vote up
async function main(): Promise<void> {
  program.requiredOption("--start <yyyy/MM>").requiredOption("--end <yyyy/MM>").requiredOption("--query <query>");

  program.parse(process.argv);

  const startDate = parse(program.start, "yyyy/MM", new Date());
  const endDate = parse(program.end, "yyyy/MM", new Date());
  const query = program.query as string;

  const allStats = [];
  for (let start = startDate; start <= endDate; start = addMonths(start, 1)) {
    const end = add(start, { months: 1, seconds: -1 });
    console.error(format(start, "yyyy-MM-dd HH:mm:ss"));
    console.error(format(end, "yyyy-MM-dd HH:mm:ss"));

    const stdout = execFileSync(
      "merged-pr-stat",
      ["--start", start.toISOString(), "--end", end.toISOString(), "--query", query],
      { encoding: "utf8" }
    );
    const result = {
      startDate: format(start, "yyyy-MM-dd HH:mm:ss"),
      endDate: format(end, "yyyy-MM-dd HH:mm:ss"),
      ...JSON.parse(stdout),
    };
    allStats.push(result);
  }
  process.stdout.write(csvStringify(allStats, { header: true }));
}
Example #13
Source File: main.ts    From squid with GNU General Public License v3.0 6 votes vote down vote up
export function run(): void {
    program.description(`
Generates TypeScript definitions for evm log events
for use within substrate-processor mapping handlers.
    `.trim())
        .requiredOption('--abi <path>', 'path to a JSON abi file')
        .requiredOption('--output <path>', 'path for output typescript file');

    program.parse();

    const options = program.opts();
    const inputPath = options.abi;
    const outputPath = options.output;

    try {
        generateTsFromAbi(inputPath, outputPath);
    } catch(err: any) {
        console.error(`evm-typegen error: ${err.toString()}`);
        process.exit(1);
    }
}
Example #14
Source File: mf-lite.ts    From mf-lite with MIT License 6 votes vote down vote up
// 创建项目
program
  .command('create')
  .description('create mf-lite project template for base-app or micro-app')
  .action(
    async () => {
      await launchPlopByConfig('micro-fe-generator');
    }
  );
Example #15
Source File: index.ts    From anchorcli with Apache License 2.0 5 votes vote down vote up
process.on('unhandledRejection', (error) => {
  if (program.verbose) {
    console.error(error);
    logger.error(error.toString());
  } else {
    logger.error(error.toString() + '; use --verbose for more details');
  }
});
Example #16
Source File: bin.ts    From gengen with MIT License 5 votes vote down vote up
program
    .command('init')
    .option('--configOutput <string>')
    .description('Creates file to select endpoints for generation')
    .action(() => gengen.init());
Example #17
Source File: cli.ts    From deskbluez with MIT License 5 votes vote down vote up
parse(argv: string[]) {
        program.parse(argv);
    }
Example #18
Source File: cli_command.ts    From ardrive-cli with GNU Affero General Public License v3.0 5 votes vote down vote up
public static parse(program: CliApiObject = programApi, argv: string[] = process.argv): void {
		program.parse(argv);
		this.rejectNonTriggeredAwaiters();
	}
Example #19
Source File: 2021-12-02-event.ts    From aurora-relayer with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
async function main(argv: string[], env: NodeJS.ProcessEnv) {
  program
    .option('-d, --debug', 'enable debug output')
    .option('-v, --verbose', 'enable verbose output')
    .option(
      '--network <network>',
      `specify NEAR network ID (default: "${env.NEAR_ENV || 'local'}")`
    )
    .option(
      '--engine <account>',
      `specify Aurora Engine account ID (default: "${
        env.AURORA_ENGINE || 'aurora.test.near'
      }")`
    )
    .option(
      '-B, --block <block>',
      `specify block height to begin indexing from (default: 0)`
    )
    .option(
      '--batch-size <batchSize>',
      `specify batch size for fetching block metadata (default: 1000)`
    )
    .parse(argv);

  const opts = program.opts() as Config;
  const [network, config] = parseConfig(
    opts,
    (externalConfig as unknown) as Config,
    env
  );
  const blockID = opts.block !== undefined ? parseInt(opts.block as string) : 0;

  if (config.debug) {
    for (const source of externalConfig.util.getConfigSources()) {
      console.error(`Loaded configuration file ${source.name}.`);
    }
    console.error('Configuration:', config);
  }

  logger.info('starting reindexing of events');
  const engine = await Engine.connect(
    {
      network: network.id,
      endpoint: config.endpoint,
      contract: config.engine,
    },
    env
  );
  const indexer = new ReindexWorker(config, network, logger, engine);
  await indexer.run(blockID, 'follow');
}
Example #20
Source File: index.ts    From backstage with Apache License 2.0 5 votes vote down vote up
main = (argv: string[]) => {
  program.name('techdocs-cli').version(version);

  registerCommands(program);

  program.parse(argv);
}
Example #21
Source File: config.ts    From nodestatus with MIT License 5 votes vote down vote up
options = program.opts()
Example #22
Source File: generate-merkle-root.ts    From merkle-distributor with MIT License 5 votes vote down vote up
json = JSON.parse(fs.readFileSync(program.input, { encoding: 'utf8' }))
Example #23
Source File: cli.ts    From protocol-v1 with Apache License 2.0 5 votes vote down vote up
function commandWithDefaultOption(commandName: string): Command {
	return program
		.command(commandName)
		.option('-e, --env <env>', 'environment e.g devnet, mainnet-beta')
		.option('-k, --keypair <path>', 'Solana wallet')
		.option('-u, --url <url>', 'rpc url e.g. https://api.devnet.solana.com');
}
Example #24
Source File: blender.ts    From yajsapi with GNU Lesser General Public License v3.0 5 votes vote down vote up
options = program.opts()
Example #25
Source File: index.ts    From tzklar-boilerplate with MIT License 5 votes vote down vote up
// configuration

program.version(packageJson.version);