How to use the args.option function in args

To help you get started, we’ve selected a few args 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 leo / cory / bin / build.js View on Github external
import path from 'path'

// Packages
import args from 'args'
import chalk from 'chalk'
import chokidar from 'chokidar'
import walk from 'walk'
import ncp from 'ncp'
import broccoli from 'broccoli'

// Ours
import config from '../lib/config'
import {isSite as exists} from '../lib/etc'
import {compile} from '../lib/compiler'

args.option('watch', 'Rebuild site if files change')
const options = args.parse(process.argv)

if (!exists()) {
  console.error(chalk.red('No site in here!'))
  process.exit(1)
}

const timerStart = new Date().getTime()

const walker = walk.walk(process.cwd(), {
  filters: [
    /\b(layouts)\b/,
    /\b(dist)\b/,
    /\b(tmp)\b/,
    /\b(node_modules)\b/,
    path.parse(config.assetDir).base
github axiom-org / axiom / ts / src / node / hserver-main.ts View on Github external
// This is the entry point for the hosting server.

import * as http from "http";
import * as os from "os";
import * as path from "path";

import args from "args";
import * as diskusage from "diskusage";

import NetworkConfig from "../iso/NetworkConfig";
import Node from "../iso/Node";
import PeerServer from "./PeerServer";
import { loadKeyPair } from "./FileUtil";

args
  .option("port", "The port on which the bootstrapper will be running", 3500)
  .option("keypair", "File containing keys", "")
  .option("network", "Which network to connect to", "local")
  .option(
    "directory",
    "The directory to store files in",
    path.join(os.homedir(), "hostfiles")
  );

const flags = args.parse(process.argv);

process.on("warning", e => console.warn(e.stack));

// Just for logging, check how much available disk space there is
try {
  let info = diskusage.checkSync(flags.directory);
github hammerframework / hammer / packages / hammer-dev-server / src / main.ts View on Github external
import chokidar from 'chokidar'
// @ts-ignore
import babelRegister from '@babel/register'

const hammerConfig = getHammerConfig()
const hammerApiDir = path.join(hammerConfig.baseDir, 'api')

babelRegister({
  extends: path.join(hammerApiDir, '.babelrc.js'),
  extensions: ['.js', '.ts'],
  only: [hammerApiDir],
  ignore: ['node_modules'],
})

// TODO: Convert to yargs.
args
  .option('port', '', hammerConfig.api.port)
  .option(
    'path',
    'The path to your lambda functions',
    hammerConfig.api.paths.functions
  )
const { port: PORT, path: PATH } = args.parse(process.argv)
const HOSTNAME = `http://localhost:${PORT}`

const showHeader = (lambdas: Record) => {
  console.log(`\n⚒ HammerFramework's API Development Server\n`)
  console.log(`◌ Listening on ${HOSTNAME}`)
  console.log(`◌ Watching ${hammerApiDir}`)
  console.log('\nNow serving\n')
  console.log(
    Object.keys(lambdas)
github interactivethings / catalog / packages / cli / src / bin / catalog-start.ts View on Github external
process.env.NODE_ENV = "development";

import args from "args";
import { errorMessage } from "../utils/format";
import { startServer } from "../server";

// Parse env

args
  .option(
    "port",
    "Port on which the Catalog server runs",
    4000,
    (port: string) => parseInt(port, 10)
  )
  .option("https", "Use https", false)
  .option("host", "Host", "localhost")
  .option("proxy", "Proxy")
  .option("babelrc", "Use local .babelrc file (defaults to true)");

const cliOptions = args.parse(process.argv, {
  value: "[source directory]",
  mri: {
    boolean: ["babelrc"]
  }
github burst-apps-team / phoenix / scripts / build.js View on Github external
const AllowedTargets = Object.keys(Targets);

function validateType(v) {

    if (!v || v === '') return v;

    if (AllowedTargets.indexOf(v) === -1) {
        console.error(`Unknown target type [${v}], allowed are:\n`);
        AllowedTargets.forEach(t => console.error(`\t- ${t}`));
        process.exit(-1);
    }
    return v;
}

args.option("target", "The target ", 'web', validateType);

const options = args.parse(process.argv);
const cwd = process.cwd();
(async function () {
    try {
        log.info(`Building Phoenix for [${chalk.bold.yellow(options.target)}]...`);
        const buildFn = Targets[options.target];
        await buildFn({
            ...options,
            cwd
        });
        log.success('Finished');
    } catch (e) {
        log.error(e);
        process.exit(-1);
    }
github dkundel / node-env-run / bin / node-env-run.js View on Github external
#!/usr/bin/env node

const fs = require('fs');
const path = require('path');
const { spawn } = require('child_process');

const args = require('args');
const dotenv = require('dotenv');

const { logger } = require('../lib/utils');

const cwd = process.cwd();

args
  .option(['f', 'force'], 'Temporarily overrides existing env variables with the ones in the .env file')
  .option(['E', 'env'], 'Location of .env file relative from the current working directory', '.env')
  .option('verbose', 'Enable verbose logging')
  .option('encoding', 'Encoding of the .env file', 'utf8');

args.config.value = '
github nodesource / nscm / bin / nscm.js View on Github external
'report',
  'verify',
  'whitelist',
  'config',
  'signin',
  'login',
  'signout',
  'logout',
  'r',
  'w',
  'c',
  's',
  'o'
]

args
  .option('registry', 'Certified modules registry', '')
  .option('token', 'Token for registry authentication', '')
  .option('production', 'Only check production', false)
  .option('concurrency', 'Concurrency of requests', config.defaults.concurrency, parseInt)
  .option('json', 'Formats the report in JSON', false)
  .option('certified', 'Shows only certified packages')
  .option('failed', 'Shows only packages that failed certification', false)
  .option('output', 'Save report to file', false)
  .option('dot', 'Formats the report in Graphiz dot', false)
  .option('svg', 'Formats the report in SVG', false)
  .option('github', 'Sign in using GitHub SSO', false)
  .option('google', 'Sign in using Google SSO', false)
  .command('report', 'Get a report of your packages', report, ['r'])
  .command('verify', 'Verify if all packages are certified', verify)
  .command('whitelist', 'Whitelist your packages', ['w'])
  .command('config', 'Configure nscm options', ['c'])
github muffin / cli / bin / build.js View on Github external
#!/usr/bin/env node

import broccoli from 'broccoli'
import chalk from 'chalk'
import args from 'args'
import { log, isSite } from '../lib/utils'
import Builder from '../lib/tasks/build'
import config from '../lib/config'

args.option('watch', 'Rebuild site if files change')

const options = args.parse(process.argv)
const tree = broccoli.loadBrocfile()

new Builder(tree, options.watch)
github vivlabs / coverage-github-reporter / src / cli.js View on Github external
#!/usr/bin/env node

const args = require('args')

args
  .option(['j', 'coverage-json'], 'Relative path to istanbul coverage JSON', 'coverage/coverage-final.json')
  .option(['h', 'coverage-html'], 'Relative path to coverage html root (for artifact links)', 'coverage/lcov-report')
  .option(['b', 'branch'], 'Base branch to use if not PR', 'master')

const {
  coverageJson,
  coverageHtml,
  branch
} = args.parse(process.argv)

const { postComment } = require('./github-comment')

try {
  const params = {
    root: process.cwd(),
    coverageJsonFilename: coverageJson,
github direct-adv-interfaces / mocha-headless-chrome / lib / cli.js View on Github external
'use strict';

const args = require('args');
const {runner} = require('./runner');
const writeFile = require('./write-file');

args.option('file', 'Path to the page which contains tests (required)')
    .option('args', 'Chrome arguments (\'--\' prefix will be added)')
    .option('reporter', 'Mocha reporter name', undefined, String)
    .option('out', 'Path to the file where test result will be saved', undefined, String)
    .option('coverage', 'Path to the file where coverage info will be saved', undefined, String)
    .option('timeout', 'Timeout in ms (defaults to 60000)', undefined, parseInt)
    .option('help', 'Output usage information', undefined, Boolean)
    .option('width', 'Viewport width', undefined, parseInt)
    .option('height', 'Viewport height', undefined, parseInt)
    .option('executablePath', 'Chrome executable path', undefined, String)
    .option('visible', 'Show Chrome window', undefined, Boolean)
    .example('mocha-headless-chrome -f test.html', 'Run tests on the "test.html" page')
    .example('mocha-headless-chrome -f http://localhost:8080', 'Run tests on the remote page')
    .example('mocha-headless-chrome -f test.html -a no-sandbox -a disable-setuid-sandbox', 'Pass the Chrome arguments')
    .example('mocha-headless-chrome -f test.html -r nyan', 'Output test result using "nyan" reporter');

let cfg = args.parse(process.argv, {