How to use the commander.option function in commander

To help you get started, we’ve selected a few commander 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 CureApp / ordinance-format-jp / bin / cli.js View on Github external
// @flow
import ordinanceFormatJp, { format } from '../src/index'
import fs from 'fs'
import Program from 'commander'
import { version } from '../package.json'

let filePath
Program
  .version(version)
  .usage(' options')
  .action(function (path) {
     filePath = path
  })

Program
  .option('--nostyle', 'outputs only the HTML structure without the style tag')
  .option('--elementId ', 'id name of the top level div tag')

Program.parse(process.argv)

if (typeof filePath === 'undefined') {
   console.error('no filePath given!')
   process.exit(1)
}

let styled = !Program.nostyle,
    elementId = Program.elementId || 'corp-site-pp'
const markdownText = fs.readFileSync(filePath, 'utf8')
const html = format(markdownText, { standalone: styled, elementId: elementId })

console.log(html)
github firebase / firebase-tools / src / index.js View on Github external
"use strict";

var program = require("commander");
var pkg = require("../package.json");
var clc = require("cli-color");
var logger = require("./logger");
var didYouMean = require("didyoumean");

program.version(pkg.version);
program.option(
  "-P, --project ",
  "the Firebase project to use for this command"
);
program.option("-j, --json", "output JSON instead of text, also triggers non-interactive mode");
program.option("--token ", "supply an auth token for this command");
program.option("--non-interactive", "error out of the command instead of waiting for prompts");
program.option("--interactive", "force interactive shell treatment even when not detected");
program.option("--debug", "print verbose debug output and keep a debug log file");
// program.option('-d, --debug', 'display debug information and keep firebase-debug.log');

var client = {};
client.cli = program;
client.logger = require("./logger");
client.errorOut = require("./errorOut").errorOut;
client.getCommand = function(name) {
  for (var i = 0; i < client.cli.commands.length; i++) {
github babel / babel / packages / babel-cli / src / babel / options.js View on Github external
"Write comments to generated output. (true by default)",
);
commander.option(
  "--retain-lines",
  "Retain line numbers. This will result in really ugly code.",
);
commander.option(
  "--compact [true|false|auto]",
  "Do not include superfluous whitespace characters and line terminators.",
  booleanify,
);
commander.option(
  "--minified",
  "Save as many bytes when printing. (false by default)",
);
commander.option(
  "--auxiliary-comment-before [string]",
  "Print a comment before any injected non-user code.",
);
commander.option(
  "--auxiliary-comment-after [string]",
  "Print a comment after any injected non-user code.",
);

// General source map formatting.
commander.option("-s, --source-maps [true|false|inline|both]", "", booleanify);
commander.option(
  "--source-map-target [string]",
  "Set `file` on returned source map.",
);
commander.option(
  "--source-file-name [string]",
github ali322 / nva / packages / nva-test-e2e / bin / index.js View on Github external
#! /usr/bin/env node

var program = require('commander')
var test = require('../lib/')
let version = require('../package.json').version

program.version(version)
program.option('-s, --server ', 'how to start project')
program.option('-c, --config ', 'customize config')
program.option('-p, --port ', 'customize port', 9876)
program.option(
  '    --browser ',
  'which browser to run e2e test',
  'chrome'
)

program.parse(process.argv)

let server = program.server
let config = program.config
let port = program.port
let browser = program.browser

test(server, config, port, browser)
github camptocamp / ngeo / buildtools / serve.js View on Github external
"use strict";

let path = require('path');
let url = require('url');

let closure = require('@camptocamp/closure-util');
let options = require('commander');
let gaze = require('gaze');
let exec = require('child_process').exec;

let log = closure.log;

options.option('-p, --port [number]', 'Port for incoming connections', parseInt, 3000);
options.option('-l, --loglevel [level]', 'Log level',  /^(silly|verbose|info|warn|error)$/i, 'info');
options.parse(process.argv);

/** @type {string} */
log.level = options.loglevel;

function compileCss() {
  log.info('ngeo', 'Compiling CSS');
  exec('make compile-css', function(error, stdout, stderr) {
    if (error !== null) {
      console.log(error);
    }
    if (stdout) {
      console.error(stdout);
    }
  });
github asgerf / tscheck / tscheck.js View on Github external
#!/usr/bin/env node 
var fs = require('fs');
var tscore = require('./tscore');
require('sugar');
var Map = require('./lib/map');
var SMap = require('./lib/smap')
var util = require('util');
var esprima = require('esprima');

var program = require('commander');
program.usage("FILE.js FILE.d.ts [options]")
program.option('--compact', 'Report at most one violation per type path')
	   .option('--missing', 'Report paths that are missing types (implies no-warn)')
	   .option('--coverage', 'Print declaration file coverage')
	   .option('--no-analysis', 'Skip static analysis (much faster)')
	   .option('--no-warn', 'Squelch type errors')
	   .option('--no-jsnap', 'Do not regenerate .jsnap file, even if older than .js file')
	   .option('--verbose', 'More verbose fatal error messages')
	   .option('--path ', 'Report only warnings on the given path', String, '')
	   .option('--stats', 'Print statistics')
	   .option('--runtime [browser|node]', 'Runtime environment to use (default: browser)', String, 'browser')
program.parse(process.argv);

if (program.args.length === 0) {
	program.help()
}

function fatalError(msg, e) {
github esy / esy / esy-install / src / bin / runYarnCommand.js View on Github external
'--mutex [:specifier]',
    'use a mutex to ensure only one yarn instance is executing',
  );
  commander.option(
    '--emoji [bool]',
    'enable emoji in output',
    boolify,
    process.platform === 'darwin',
  );
  commander.option(
    '-s, --silent',
    'skip Yarn console logs, other types of logs (script output) will be printed',
  );
  commander.option('--cwd ', 'working directory to use', process.cwd());
  commander.option('--proxy ', '');
  commander.option('--https-proxy ', '');
  commander.option('--registry ', 'override configuration registry');
  commander.option('--no-progress', 'disable progress bar');
  commander.option(
    '--network-concurrency ',
    'maximum number of concurrent network requests',
    parseInt,
  );
  commander.option(
    '--network-timeout ',
    'TCP timeout for network requests',
    parseInt,
  );
  commander.option('--non-interactive', 'do not show interactive prompts');
  commander.option(
    '--scripts-prepend-node-path [bool]',
    'prepend the node executable dir to the PATH in scripts',
github walkdoer / Life-Time-Tracker / tracker / ltt.js View on Github external
.description('对某一个行为进行提醒,例如喝水提醒,日程提醒')
    .action(remind);

program
    .command('action ')
    .description('执行某一个动作,例如喝水drink')
    .action(takeAction);

program
    .option('-t, --top ', 'top N of a list', number)
    .option('-o, --order ', 'desc or asc')
    .command('tags ')
    .description('列出某段时间的tags')
    .action(wrapDateProcess(listTags));

program
    .option('-t, --top ', 'top N of a list', number)
    .option('-o, --order ', 'desc or asc')
    .command('projects ')
    .description('列出某段时间的进行的项目')
    .action(wrapDateProcess(listProjects));

program
    .command('server')
    .option('-p,--port ', 'server listen port')
    .description('开启服务器')
    .action(startServer);
program
    .option('--type ', '需要导入的类型,例如logs,projects')
    .command('import ')
    .description('导入某一段时间的日志')
    .action(wrapDateProcess(importLogs));
github vega / ts-json-schema-generator / dist / typescript-to-json-schema.js View on Github external
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const commander = require("commander");
const stringify = require("json-stable-stringify");
const generator_1 = require("./factory/generator");
const Config_1 = require("./src/Config");
const BaseError_1 = require("./src/Error/BaseError");
const formatError_1 = require("./src/Utils/formatError");
const args = commander
    .option("-p, --path 
github sx1989827 / DOClever / node_modules / html-minifier / cli.js View on Github external
program.option('--' + paramCase(key), option);
  }
});
program.option('-o --output ', 'Specify output file (if not specified STDOUT will be used for output)');

function readFile(file) {
  try {
    return fs.readFileSync(file, { encoding: 'utf8' });
  }
  catch (e) {
    fatal('Cannot read ' + file + '\n' + e.message);
  }
}

var config = {};
program.option('-c --config-file ', 'Use config file', function(configPath) {
  var data = readFile(configPath);
  try {
    config = JSON.parse(data);
  }
  catch (je) {
    try {
      config = require(path.resolve(configPath));
    }
    catch (ne) {
      fatal('Cannot read the specified config file.\nAs JSON: ' + je.message + '\nAs module: ' + ne.message);
    }
  }
  mainOptionKeys.forEach(function(key) {
    if (key in config) {
      var option = mainOptions[key];
      if (Array.isArray(option)) {