How to use the args.sub 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 mfix22 / gest / bin / gest.js View on Github external
.then(() => console.log())
      .catch((/* err */) => {
        console.log('\n' + errors)
        process.exit(1)
      })
  } else {
    if (flags.print) {
      const q = args.sub[0] || flags.print
      return wrapLogging(
        getQueryString(q)
          .then(GraphQL.parse)
          .then(GraphQL.print)
      )
    }
    if (args.sub && args.sub.length) {
      args.sub.map(q =>
        wrapLogging(
          getQueryString(q)
            .then(gest(schema, options))
            .then(res => {
              const message = colorResponse(res) + '\n'
              if (res.errors) {
                throw '\n' + message
              }
              return message
            })
        )
      )
    } else {
      // Open REPL
      REPL(schema, options)
    }
github mfix22 / gest / bin / gest.js View on Github external
.then(tasks => tasks.run())
      .then(() => console.log())
      .catch((/* err */) => {
        console.log('\n' + errors)
        process.exit(1)
      })
  } else {
    if (flags.print) {
      const q = args.sub[0] || flags.print
      return wrapLogging(
        getQueryString(q)
          .then(GraphQL.parse)
          .then(GraphQL.print)
      )
    }
    if (args.sub && args.sub.length) {
      args.sub.map(q =>
        wrapLogging(
          getQueryString(q)
            .then(gest(schema, options))
            .then(res => {
              const message = colorResponse(res) + '\n'
              if (res.errors) {
                throw '\n' + message
              }
              return message
            })
        )
      )
    } else {
      // Open REPL
      REPL(schema, options)
github zeit / release / bin / release.js View on Github external
);
	process.exit(1);
}

args.option('pre', 'Mark the release as prerelease')
	.option('overwrite', 'If the release already exists, replace it')
	.option('publish', 'Instead of creating a draft, publish the release')
	.option(['H', 'hook'], 'Specify a custom file to pipe releases through')
	.option(['t', 'previous-tag'], 'Specify previous release', '')
	.option(['u', 'show-url'], 'Show the release URL instead of opening it in the browser');

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

// When running `release pre`, the release
// should automatically be marked as a pre-release
if (args.sub[0] === 'pre') {
	flags.pre = true;
}

let githubConnection;
let repoDetails;

const changeTypes = [
	{
		handle: 'major',
		name: 'Major Change',
		pluralName: 'Major Changes',
		description: 'incompatible API change'
	},
	{
		handle: 'minor',
		name: 'Minor Change',
github zeit / release / bin / release.js View on Github external
#!/usr/bin/env node --harmony-async-await

// Packages
const args = require('args')

// Utilities
const validateProject = require('../utils/validate')

args.parse(process.argv)

// Make sure that the project is ready for releases
// If it's not, throw errors to indicate the exact problem
validateProject(args.sub)

const releaseType = args.sub[0]
console.log(releaseType)
github muffin / cli / bin / new.js View on Github external
import inquirer from 'inquirer'
import gitConfig from 'git-config'
import chalk from 'chalk'
import mkdirp from 'mkdirp'

import { log, isSite } from '../lib/utils'
import Generator from '../lib/tasks/generate'

args
  .option('yes', 'Skip all questions')
  .option('force', 'If the current directory contains a site, overwrite it')
  .option(['n', 'skip-npm'], 'Skip installing dependencies')
  .option(['d', 'skip-data'], 'Don\'t insert sample data')

const options = args.parse(process.argv)
const directory = args.sub[0]

// Resolve the path of the directory or use the current working dir
const targetDir = directory ? path.resolve(process.cwd(), directory) : process.cwd()

if (targetDir == path.normalize(__dirname + '/../../template')) {
  log('You shouldn\'t run ' + chalk.gray('init') + ' in here.')
  log('Please run it somewhere outside of the project.')

  process.exit(0)
}

if (isSite() && !options.force) {
  log(chalk.red('There\'s already a site in here!'))
  process.exit(1)
}
github zeit / serve / lib / index.js View on Github external
// Ours
const listening = require('./listening')
const serverHandler = require('./server')

args
  .option('port', 'Port to listen on', process.env.PORT || 3000)
  .option('cache', 'How long static files should be cached in the browser (seconds)', 3600)
  .option('single', 'Serve single page apps with only one index.html')
  .option('unzipped', 'Disable GZIP compression')
  .option('ignore', 'Files and directories to ignore', '')
  .option('auth', 'Serve behind basic auth')
  .option(['o', 'cors'], 'Setup * CORS headers to allow requests from any origin', false)

const flags = args.parse(process.argv)
const directory = args.sub[0]

process.env.ASSET_DIR = '/' + Math.random().toString(36).substr(2, 10)

let current = process.cwd()

if (directory) {
  current = path.resolve(process.cwd(), directory)
}

let ignoredFiles = [
  '.DS_Store',
  '.git/'
]

if (flags.ignore && flags.ignore.length > 0) {
  ignoredFiles = ignoredFiles.concat(flags.ignore.split(','))
github FriendsOfFlarum / extension-generator / src / index.js View on Github external
const editor = require('mem-fs-editor');
const yosay = require('yosay');
const ora = require('ora');
const { reset } = require('chalk');

const licenseList = Array.from(require('spdx-license-list/simple'));

args.option(
  'path',
  'The root directory in which to create the Flarum extension',
  process.cwd(),
  p => path.resolve(p)
);

const flags = args.parse(process.argv);
const dir = (args.sub[0] && path.resolve(args.sub[0])) || flags.path;
const store = memFs.create();
const fs = editor.create(store);

const onCancel = () => process.exit();
const initial = true;
let spinner;

console.log(yosay('Welcome to a Flarum extension generator\n\n- FriendsOfFlarum'));

new Promise((resolve, reject) => {
  spinner = ora('Starting...').start();
  filesystem.readdir(dir, (err, files = []) => {
    spinner.stop();
    resolve((!err || err.code !== 'ENOENT') && files.length !== 0);
  });
})
github muffin / cli / bin / import.js View on Github external
#!/usr/bin/env node

import args from 'args'
import chalk from 'chalk'
import { log, isSite } from '../lib/utils'
import Insert from '../lib/tasks/insert'
import config from '../lib/config'

args.parse(process.argv)
const which = args.sub

if (which.length === 0) {
  log('You need to specify a file or directory: ' + chalk.grey('muffin import file.json'))
  process.exit(1)
}

new Insert(which)
github moleculerjs / moleculer / bin / moleculer-runner.js View on Github external
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"]
		}
	});

	servicePaths = Args.sub;
}
github nodesource / nscm / bin / nscm-config.js View on Github external
const args = require('args')
const chalk = require('chalk')
const config = require('../commands/config')
const tools = require('../lib/tools')

args
  .command('set', `Sets a configuration option ${chalk.gray('(eg: set depth 2)')}`, config.set, ['s'])
  .command('get', `Gets a configuration option ${chalk.gray('(eg: get registry)')}`, config.get, ['g'])
  .command('delete', `Deletes a configuration option ${chalk.gray('(eg: delete token)')}`, config.del, ['d'])
  .command('list', 'List all configuration options', config.list, ['l'])
  .command('reset', 'Reset all configuration options', config.reset, ['r'])
  .parse(process.argv, {
    usageFilter: tools.usageFilter
  })

if (!args.sub.length) {
  args.showHelp()
}