How to use caporal - 10 common examples

To help you get started, we’ve selected a few caporal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fabiospampinato / enex-dump / src / cli.js View on Github external
.action ( () => EnexDump () );

  /* HELP */

  const command = app._defaultCommand;
  const helpLines = [
    `enex-dump ${chalk.green ( '--src' )} ${chalk.blue ( './my-notes.enex' )}`,
    `enex-dump ${chalk.green ( '--src' )} ${chalk.blue ( './my-notes.enex' )} ${chalk.green ( '--format' )} ${chalk.blue ( 'html' )} ${chalk.green ( '--extension' )} ${chalk.blue ( 'html' )}`,
    `enex-dump ${chalk.green ( '--src' )} ${chalk.blue ( './my-notes.enex' )} ${chalk.green ( '--no-metadata' )} ${chalk.green ( '--no-attachments' )}`
  ];

  command.help ( helpLines.join ( '\n' ), { name: 'USAGE - ADVANCED' } );

  /* PARSE */

  caporal.parse ( process.argv );

}
github fabiospampinato / template / src / cli.ts View on Github external
.action ( () => Template.list () )
    /* INSTALL */
    .command ( 'install', 'Install a template from a repository' )
    .argument ( '', 'Git endpoint url, GitHub shorthand or local path' )
    .argument ( '[template]', 'Template name' )
    .action ( args => Template.install ( args.repository, args.template ) )
    /* UNINSTALL */
    .command ( 'uninstall', 'Uninstall one or all templates' )
    .argument ( '[template]', 'Template name' )
    .action ( args => Template.uninstall ( args.template ) )
    /* UPDATE */
    .command ( 'update', 'Update one or all templates' )
    .argument ( '[template]', 'Template name' )
    .action ( args => Template.update ( args.template ) );

  caporal.parse ( process.argv );

}
github axetroy / webuild / index.js View on Github external
require("@axetroy/graceful")();
const path = require("path");
const program = require("caporal");
const pkg = require("./package.json");
const CONFIG = require("./src/config")();

// 可用的编译类型
const availableTypes = {
  wechat: 1,
  alipay: 1
};

const p = program.version(pkg.version).description(pkg.description);

p
  .command("dev")
  .option("--src <dir>", "源码目录", program.STRING, "src")
  .option("--output <dir>", "输出目录", program.STRING, "dist")
  .option(
    "--type ",
    "微信(wechat)/支付宝(alipay)",
    program.STRING,
    "wechat"
  )
  .description("以开发模式运行")
  .action(function(argv, options) {
    process.env.NODE_ENV = "development";
    CONFIG.isProduction = false;
    CONFIG.type = options.type;</dir></dir>
github crawlab-team / artipub / cli.js View on Github external
const port = cmdObj.port || '27017'
    const db = cmdObj.db || 'artipub'
    const username = cmdObj.username || ''
    const password = cmdObj.password || ''

    process.env.MONGO_HOST = host
    process.env.MONGO_PORT = port
    process.env.MONGO_DB = db
    process.env.MONGO_USERNAME = username
    process.env.MONGO_PASSWORD = password

    // 开启后段服务
    require('./server')
  })

program.parse(process.argv)
github albacoretuna / moro / bin / moro.js View on Github external
// note
  //
  .command('note', COMMAND_DESCRIPTIONS.note)
  .alias('n')
  .argument('[note...]', COMMAND_DESCRIPTIONS.noteNote)
  .action(commands.addNote)
  //
  // ////////////////////
  // about
  //
  .command('about', COMMAND_DESCRIPTIONS.about)
  .alias('a')
  .action(commands.about)

// let it begin!
prog.parse(process.argv)
github karlitos / KissMyResume / cli.js View on Github external
* @param opt {string} The port option flag value
 * @returns {port} The processed out option flag value
 */
const serverPortOptionValidator = (opt) =&gt; {
	const portNr = parseInt(opt);
	if (!(Number.isInteger(portNr) &amp;&amp; portNr &gt;= 0 &amp;&amp; portNr &lt;= 65535)) {
		throw new Error(`The provided value ${opt} is not valid port number!`);
	}
	return portNr;
};


// Get the version from package.json
const version = require('./package.json').version;
// Provide it in the CLI
program.version(version, '-v, --version');

// CLI setting for the "build" command
program.command('build', 'Build your resume to the destination format(s).')
	.argument('<source>', 'The path to the source JSON resume file.')
	.option('-f, --format ', 'Set output format (HTML|PDF|YAML|DOCX|PNG|ALL)', formatOptionValidator, 'all')
	.option('-o, --out ', 'Set output directory', outOptionValidator, DEFAULT_OUTPUT_PATH)
	.option('-n, --name ', 'Set output file name', nameOptionValidator, DEFAULT_NAME)
	.option('-t, --theme ', 'Set the theme you wish to use', themeOptionValidator, DEFAULT_THEME)
	.action((args, options) =&gt; {


		logInfo(`+++ KissMyResume v${version} +++`);

		const sourcePath = path.resolve(process.cwd(), args.source );

		switch (options.format) {
github fabiospampinato / pacco / src / cli.js View on Github external
async function CLI () {

  /* GULP */

  gutil.patch ();

  /* APP */

  const {pkg} = await readPkg ({ cwd: __dirname });

  updateNotifier ({ pkg }).notify ();

  const app = caporal.version ( pkg.version );

  /* OPTIONS */

  app.option ( '--source, --src, -s 
github handsontable / hot-builder / src / main.js View on Github external
function parseArgs() {
  program
    .version(packageVersion)
    // the "build" command
    .command('build', 'Build Handsontable Community Edition or Handsontable PRO package')
    .option(
      '-i, --input <dir>',
      'Path to a directory where Handsontable Community Edition or Handsontable PRO repository was downloaded',
      resolve
    )
    .option(
      '-o, --output-dir <dir>',
      'Output directory where generated bundle will be saved',
      resolve,
      void 0,
      true
    )
    .option(</dir></dir>
github fabiospampinato / enex-dump / src / cli.js View on Github external
async function CLI () {

  /* APP */

  const {pkg} = await readPkg ({ cwd: __dirname });

  updateNotifier ({ pkg }).notify ();

  const app = caporal.version ( pkg.version );

  /* COMMAND */

  app.option ( '--src 
github wix / okidoc / packages / okidoc-md / bin / okidoc-md.js View on Github external
#!/usr/bin/env node

const program = require('caporal');

const pkg = require('../package.json');

const runCLI = require('../lib/cli').default;

program
  .version(pkg.version)
  .description('okidoc-md')
  .argument('[configPath]', 'Config file path', program.STRING, './docs.yml')
  .argument('[outputDir]', 'Markdown output dir', program.STRING, './docs')
  .option('-c --config ', 'Config file path', program.STRING)
  .option('-o --output ', 'Markdown output base dir', program.STRING)
  .action((args, options) =&gt; {
    runCLI({
      configPath: options.config || args.configPath,
      outputDir: options.output || args.outputDir,
    }).catch(error =&gt; {
      console.error('An error occurred while building documentation.', error);
      process.exit(1);
    });
  });

caporal

A full-featured framework for building command line applications (cli) with node.js

MIT
Latest version published 4 years ago

Package Health Score

52 / 100
Full package analysis

Popular caporal functions