JSPM

@oclif/core

3.0.0-beta.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3985649
  • Score
    100M100P100Q215210F
  • License MIT

base library for oclif CLIs

Package Exports

  • @oclif/core
  • @oclif/core/execute
  • @oclif/core/flush
  • @oclif/core/handle
  • @oclif/core/interfaces
  • @oclif/core/run
  • @oclif/core/settings
  • @oclif/core/ux

Readme

@oclif/core

base library for oclif CLIs

Version Downloads/week License

Migrating

See the v2 migration guide for an overview of breaking changes that occurred between v1 and v2.

See the v3 migration guide for an overview of breaking changes that occurred between v2 and v3.

CLI UX

The ux README contains detailed usage examples of using the ux export.

Usage

We strongly encourage you generate an oclif CLI using the oclif cli. The generator will generate an npm package with @oclif/core as a dependency.

You can, however, use @oclif/core in a standalone script like this:

#!/usr/bin/env ts-node

import * as fs from 'fs'
import {Command, Flags, flush, handle} from '@oclif/core'

class LS extends Command {
  static description = 'List the files in a directory.'
  static flags = {
    version: Flags.version(),
    help: Flags.help(),
    dir: Flags.string({
      char: 'd',
      default: process.cwd(),
    }),
  }

  async run() {
    const {flags} = await this.parse(LS)
    const files = fs.readdirSync(flags.dir)
    for (const f of files) {
      this.log(f)
    }
  }
}

LS.run().then(async () => {
  await flush()
}, async (err) => {
  await handle(err)
})

Then run it like this:

$ ts-node myscript.ts
...files in current dir...