How to use the args.parse 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 jaretburkett / electron-icon-maker / index.js View on Github external
#!/usr/bin/env node

const Jimp = require("jimp");
const args = require('args');
const path = require('path');
const fs = require('fs');
const icongen = require( 'icon-gen' );

var pngSizes = [16, 24, 32, 48, 64, 128, 256, 512, 1024];

args
    .option('input', 'Input PNG file. Recommended (1024x1024)', './icon.png')
    .option('output', 'Folder to output new icons folder', './');

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

// correct paths
var input = path.resolve(process.cwd(), flags.input);
var output = path.resolve(process.cwd(), flags.output);
var o = output;
var oSub = o.endsWith('/') ? o + 'icons/' : o + '/icons/';
var PNGoutputDir = oSub + 'png/';

const iconOptions = {
    type: 'png',
    report: true
};

// do it
createPNGs(0);
github T-Specht / ts-typie / app.ts View on Github external
// look for the first available tool
let defaultTool;
for (const tool of Object.keys(tools)) {
    if (commandExists.sync(tool)) {
        defaultTool = tool;
        break;
    }
}
if (defaultTool === undefined) {
    console.error('Couldn\'t find a supported package manager tool.')
}

// support for overriding default
args.option('tool', 'Which package manager tool to use', defaultTool);
const opts = args.parse(process.argv, {
    name: 'ts-typie',
    mri: undefined,
    mainColor: 'yellow',
    subColor: 'dim'
});
const tool = tools[opts.tool];



// check if package.json exists

const cwd = process.cwd();
const packagePath = path.join(cwd, 'package.json');

if (!fs.existsSync(packagePath)) {
    console.error('No package.json file found!');
github xiaodoudou / PlexIPTV / index.js View on Github external
args
  .option('logdir', 'The path where the log files will be written', _.get(process, 'env.PLEXIPTV_LOGDIR', path.join(process.cwd(), 'logs')))
  .option('settings ', 'Path of the configuration file', _.get(process, 'env.PLEXIPTV_SETTINGS', path.join(process.cwd(), 'settings.json')))

const express = require('express')
const Q = require('q')
const request = require('request')
const fs = require('fs')
const validUrl = require('valid-url')
const Preloader = require('./preloader')
const DVR = require('./dvr')
const Config = require('./config')
const Logger = new (require('./logger'))()
const packageJson = require('./package.json')
const flags = args.parse(process.argv)

class Server {
  constructor () {
    this.express = express()
    this.preloader = new Preloader()
    this.config = new Config()
    this.channels = []

    // Bindings
    this.pullPlaylist = this.pullPlaylist.bind(this)
    this.readPlaylist = this.readPlaylist.bind(this)
    this.proxy = this.proxy.bind(this)
  }

  init () {
    this.config.init().then(settings => {
github leo / cory / bin / index.js View on Github external
// Packages
import args from 'args'
import updateNotifier from 'update-notifier'

// Ours
import pkg from '../../package.json'

updateNotifier({pkg}).notify()

args
  .command('serve', 'Serve your site locally')
  .command('build', 'Buily your site')
  .command('init', 'Generate a new site in the current directory')
  .command('clean', 'Remove the generated output')

args.parse(process.argv)
github zeit / release / lib / index.js View on Github external
// Ours
const groupChanges = require('../lib/group')
const {branchSynced, getRepo} = require('../lib/repo')
const getCommits = require('../lib/commits')
const getChoices = require('../lib/choices')
const definitions = require('../lib/definitions')
const connect = require('../lib/connect')
const createChangelog = require('../lib/changelog')
const handleSpinner = require('../lib/spinner')

args
  .option('pre', 'Mark the release as prerelease')
  .option('overwrite', 'If the release already exists, replace it')

const flags = args.parse(process.argv)

let githubConnection
let repoDetails

const changeTypes = [
  {
    handle: 'major',
    name: 'Major Change',
    description: 'incompatible API change'
  },
  {
    handle: 'minor',
    name: 'Minor Change',
    description: 'backwards-compatible functionality'
  },
  {
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,
    coverageHtmlRoot: coverageHtml,
    defaultBaseBranch: branch
  }
  const url = postComment(params)
  console.log('Posted to ', url)
} catch (err) {
  console.error(err)
}
github moleculerjs / moleculer / src / runner.js View on Github external
processFlags(procArgs) {
		Args
			.option("config", "Load the configuration from a file")
			.option("repl", "Start REPL mode", false)
			.option(["H", "hot"], "Hot reload services if changed", false)
			.option("silent", "Silent mode. No logger", false)
			.option("env", "Load .env file from the current directory")
			.option("envfile", "Load a specified .env file")
			.option("instances", "Launch [number] instances node (load balanced)")
			.option("mask", "Filemask for service loading");

		this.flags = Args.parse(procArgs, {
			mri: {
				alias: {
					c: "config",
					r: "repl",
					H: "hot",
					s: "silent",
					e: "env",
					E: "envfile",
					i: "instances",
					m: "mask"
				},
				boolean: ["repl", "silent", "hot", "env"],
				string: ["config", "envfile", "mask"]
			}
		});
github Azure / Azurite / src / blob / BlobEnvironment.ts View on Github external
"Optional. Disable access log displayed in console"
    )
    .option(
      ["L", "loose"],
      "Optional. Enable loose mode which ignores unsupported headers and parameters"
    )
    .option(
      ["d", "debug"],
      "Optional. Enable debug log by providing a valid local file path as log destination"
    );

  (args as any).config.name = "azurite-blob";
}

export default class BlobEnvironment implements IBlobEnvironment {
  private flags = args.parse(process.argv);

  public blobHost(): string | undefined {
    return this.flags.blobHost;
  }

  public blobPort(): number | undefined {
    return this.flags.blobPort;
  }

  public async location(): Promise {
    const location = this.flags.location || process.cwd();
    await accessAsync(location);
    return location;
  }

  public silent(): boolean {