How to use the cac.default function in cac

To help you get started, we’ve selected a few cac 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 upash / peco / bin / cli.js View on Github external
#!/usr/bin/env node
if (parseInt(process.versions.node, 10) < 8) {
  const chalk = require('chalk')
  console.error(
    chalk.red(
      `Peco requires Node.js version >= 8, please upgrade!\nCheck out ${chalk.underline(
        'https://nodejs.org'
      )}`
    )
  )
  process.exit(1)
}

const cac = require('cac').default

const cli = cac()

cli
  .command('dev', 'Develop website locally', (input, flags) => {
    const app = require('../lib')(Object.assign({ baseDir: input[0] }, flags))

    return app.dev()
  })
  .option('port', {
    desc: 'Port for dev server',
    type: 'number'
  })

cli.command('build', 'Build website to static HTML files', (input, flags) => {
  const app = require('../lib')(Object.assign({ baseDir: input[0] }, flags))

  return app.build()

cac

Simple yet powerful framework for building command-line apps.

MIT
Latest version published 2 years ago

Package Health Score

75 / 100
Full package analysis