Nested Parenthetical Madness

    @oclif/core
    TypeScript icon, indicating that this package has built-in type declarations

    1.20.4 • Public • Published

    @oclif/core

    base library for oclif CLIs

    Version CircleCI Downloads/week License

    Migrating

    If you're migrating from the old oclif libraries (@oclif/config, @oclif/command, @oclif/error, @oclif/parser), see the migration guide.

    The @oclif/core module now also includes the cli-ux module. Merging cli-ux into @oclif/core resolves a circular dependency between the two modules. See the cli-ux README for instructions on how to replace the cli-ux module with @oclif/core. The cli-ux README also contains detailed usage examples.

    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} 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(() => {
      require('@oclif/core/flush')
    }, () => {
      require('@oclif/core/handle')
    })

    Then run it like this:

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

    Keywords

    Install

    npm i @oclif/core

    DownloadsWeekly Downloads

    657,603

    Version

    1.20.4

    License

    MIT

    Unpacked Size

    296 kB

    Total Files

    150

    Last publish

    Collaborators

    • rodesp
    • mdonnalley
    • rasphilco
    • dickeyxxx
    • amphro
    • chadian
    • salesforce-releases