How to use the caporal.version function in caporal

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 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 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);
    });
  });
github TimboKZ / Rammy / bin / rammy-cli.js View on Github external
rammyrcPath: Util.discoverRammyrc(process.cwd()),
};
if (config.rammyrcPath) logger.debug(`Discovered config: ${config.rammyrcPath}`);
const rammy = new Rammy(config);

const handleError = (error) =&gt; {
    if (error instanceof Util.RammyError) {
        logger.error(error.message);
        if (error.comment) logger.warn(error.comment);
    }
    else console.error(error);
    process.exit(1);
};

cli.logger(logger);
cli.version(packageData.version);

//--------- Init
cli
    .command('init', 'Initialise a Rammy LaTeX project')
    .argument('[dir]', 'Target directory', null, process.cwd())
    .option('-g, --git', 'Initialise a Git repo with .gitignore', cli.BOOL, false)
    .action((args, options) =&gt; {
        Promise.resolve()
            .then(() =&gt; rammy.initProject({directory: path.resolve(args.dir), initGit: options.git}))
            .catch(handleError);
    });
cli
    .command('init-module', 'Initialise a Rammy module')
    .argument('', 'Name of the module')
    .argument('[dir]', 'Target directory', null, process.cwd())
    .action((args) =&gt; {
github MitocGroup / recink / bin / cli.js View on Github external
logger.info(logger.emoji.rocket, 'Done.');
      process.exit(0);
    }).catch(error =&gt; {
      logger.error(error);
      process.exit(1);
    });
  };
}

let description = pkg.description;

if (Env.isCI) {
  description += ' [CI Build]';
}

const commands = prog
  .version(pkg.version)
  .description(description)
  .command('run', 'Run generic component')
  .argument('[name]', 'Generic component name')
  .argument('[path]', 'Path to tests', /.+/, process.cwd())
  .option('--exclude-modules [modules]', 'List of modules to exclude', prog.LIST, [])
  .option('--include-modules [modules]', 'List of modules to run', prog.LIST, [])
  .option('--custom-config', 'Custom configuration', prog.LIST, [])
  .option('--tf-version', 'Terraform version',  /.*/, false)
  .option('--tf-workspace', 'Terraform workspace', /.*/, false)
  .option('--tf-vars', 'Terraform variables as environmental variables', prog.LIST, [])
  .option('--tf-varfiles', 'Terraform variables as tfvars files', prog.LIST, [])
  .option('--sync', 'Synchronize with cnci', prog.BOOL, false)
  .option('-s ', 'Skip component', prog.REPEATABLE)
  .option('--registry-path [path]', 'Custom path for .recink', /.+/, ComponentRegistry.DEFAULT_STORAGE_PATH)
  .complete(() =&gt; [ 'preprocess', 'cache', 'emit', 'npm', 'test', 'coverage' ])
github arcjet / arcjet / src / arcjet.ts View on Github external
#!/usr/bin/env node
import * as program from 'caporal'
import * as fs from 'fs'
import * as path from 'path'
import * as got from 'got'

import Store from './store'
import { server } from './server'
const pkg = require('../package.json')

const DEFAULT_PORT = 3000

program.version(pkg.version)

program
  .command('start', 'Start server with a database file')
  .argument('', 'File to start the database with')
  .option(
    '--port ',
    'Port number to listen on',
    program.INT,
    DEFAULT_PORT,
    true,
  )
  .action(async (args, options, logger) =&gt; {
    try {
      const store = new Store()
      await store.init(args.file)
      await server(store, parseInt(options.port, 10) || DEFAULT_PORT)
github wix / okidoc / packages / okidoc-site / bin / okidoc-site.js View on Github external
#!/usr/bin/env node

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

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

const DEFAULT_CONFIG_PATH = './site.yml';

program
  .version(pkg.version)
  .description('okidoc-site')
  .command(
    'develop',
    `Start development server. Watches files, rebuilds, and hot reloads if something changes`,
  )
  .argument(
    '[configPath]',
    'Config file path',
    program.STRING,
    DEFAULT_CONFIG_PATH,
  )
  .action(({ configPath }, {}, logger) => {
    runCLI('develop', { configPath }, logger);
  })
  .command('build', `Build a Gatsby project`)

caporal

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

MIT
Latest version published 5 years ago

Package Health Score

52 / 100
Full package analysis

Popular caporal functions