How to use the cac.parse 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 egoist / poi / packages / poi / bin / main.js View on Github external
const cac = require('cac')
const updateNotifier = require('update-notifier')
const Poi = require('../lib')
const isPath = require('../lib/utils/isPath')
const pkg = require('../package')

require('loud-rejection')()

updateNotifier({ pkg }).notify()

// To start Poi, we will need to know which `command` you're calling
// And you can also supply options via CLI flags
const { input, flags } = cac.parse(process.argv.slice(2))

// Handle `--version` before starting Poi
if (flags.version || flags.v) {
  console.log(require('../package').version)
  process.exit()
}

// Get command from CLI input
// When there's no input or the first element of input is a file path
// We think you're in the `develop` command
// Otherwise you're in the `input[0]` command
// And the rest of input becomes the webpack `entry`
let command
let entry
if (!input[0] || isPath(input[0])) {
  command = 'develop'
github saojs / sao / lib / utils / config.js View on Github external
const getConfigOptions = options => {
  const { flags } = cac.parse(process.argv.slice(2))
  return Object.assign(
    {
      flags
    },
    options
  )
}

cac

Simple yet powerful framework for building command-line apps.

MIT
Latest version published 2 years ago

Package Health Score

77 / 100
Full package analysis