How to use the args.command 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 zeit / hyper / cli / index.ts View on Github external
} else {
          let msg = columnify(entries);
          spinner.succeed();
          msg = msg.substring(msg.indexOf('\n') + 1); // remove header
          console.log(msg);
        }
      })
      .catch(err => {
        spinner.fail();
        console.error(chalk.red(err)); // TODO
      });
  },
  ['s']
);

args.command(
  'list-remote',
  'List plugins available on npm',
  () => {
    const spinner = ora('Searching').start();

    commandPromise = lsRemote()
      .then(entries => {
        let msg = columnify(entries);

        spinner.succeed();
        msg = msg.substring(msg.indexOf('\n') + 1); // remove header
        console.log(msg);
      })
      .catch(err => {
        spinner.fail();
        console.error(chalk.red(err)); // TODO
github zeit / hyper / cli / index.ts View on Github external
.then(entries => entries.map(entry => entry.package))
    .then(entries => entries.filter(entry => entry.name.indexOf(PLUGIN_PREFIX) === 0))
    .then(entries =>
      entries.map(({name, description}) => {
        return {name, description};
      })
    )
    .then(entries =>
      entries.map(entry => {
        entry.name = chalk.green(entry.name);
        return entry;
      })
    );
};

args.command(
  'search',
  'Search for plugins on npm',
  (name, args_) => {
    const spinner = ora('Searching').start();
    const query = args_[0] ? args_[0].toLowerCase() : '';

    commandPromise = lsRemote(query)
      .then(entries => {
        if (entries.length === 0) {
          spinner.fail();
          console.error(chalk.red(`Your search '${query}' did not match any plugins`));
          console.error(`${chalk.red('Try')} ${chalk.green('hyper ls-remote')}`);
          process.exit(1);
        } else {
          let msg = columnify(entries);
          spinner.succeed();
github zeit / hyper / cli / index.ts View on Github external
args.command(
  'uninstall',
  'Uninstall a plugin',
  (name, args_) => {
    checkConfig();
    const pluginName = args_[0];
    assertPluginName(pluginName);
    commandPromise = api
      .uninstall(pluginName)
      .then(() => console.log(chalk.green(`${pluginName} uninstalled successfully!`)))
      .catch(err => console.log(chalk.red(err)));
  },
  ['u', 'rm', 'remove']
);

args.command(
  'list',
  'List installed plugins',
  () => {
    checkConfig();
    const plugins = api.list();

    if (plugins) {
      console.log(plugins);
    } else {
      console.log(chalk.red(`No plugins installed yet.`));
    }
    process.exit(0);
  },
  ['ls']
);
github zeit / hyper / cli / index.ts View on Github external
process.exit(0);
  },
  ['d', 'h', 'home']
);

args.command(
  'version',
  'Show the version of hyper',
  () => {
    console.log(version);
    process.exit(0);
  },
  []
);

args.command('', 'Launch Hyper');

args.option(['v', 'verbose'], 'Verbose mode', false);

const main = (argv: string[]) => {
  const flags = args.parse(argv, {
    name: 'hyper',
    version: false,
    mri: {
      boolean: ['v', 'verbose']
    }
  } as any);

  if (commandPromise) {
    return commandPromise;
  }
github rtsao / create-universal-package / packages / create-universal-package / bin / index.js View on Github external
#!/usr/bin/env node

const args = require('args');
args
  .command('build', 'Build your package', ['b'])
  .command('build-tests', 'Build your tests')
  .command('clean', 'Clean build artifacts', ['c']);

args.parse(process.argv);
github muffin / cli / bin / index.js View on Github external
#!/usr/bin/env node

import args from 'args'
import updateNotifier from 'update-notifier'
import pkg from '../../package.json'

updateNotifier({ pkg }).notify()

args
  .command('build', 'Build your site')
  .command('new', 'Generate the boilerplate for a new site')
  .command('serve', 'Serve your site locally')
  .command('import', 'Import data into your site\'s database')

args.parse(process.argv)