Skip to content

deian/core

This branch is 3 commits ahead of, 1205 commits behind oclif/core:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

68d3553 · Aug 9, 2022
May 6, 2022
Jun 14, 2022
Apr 15, 2021
Aug 9, 2022
Jul 22, 2022
Jul 3, 2020
Jul 3, 2020
Sep 24, 2021
Jul 3, 2020
Jan 26, 2022
Jun 16, 2022
Aug 9, 2022
Jul 3, 2020
Jul 15, 2022
Jan 26, 2022
Apr 15, 2021
Sep 2, 2020
Jul 14, 2022
Sep 2, 2020
Aug 9, 2022
Jul 22, 2022
Aug 8, 2022

Repository files navigation

@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

Without the generator, you can create a simple CLI like this:

TypeScript

#!/usr/bin/env ts-node

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

class LS extends Command {
  static flags = {
    version: Flags.version(),
    help: Flags.help(),
    // run with --dir= or -d=
    dir: Flags.string({
      char: 'd',
      default: process.cwd(),
    }),
  }

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

LS.run()
.catch(require('@oclif/core/handle'))

Then run either of these with:

$ ./myscript
...files in current dir...
$ ./myscript --dir foobar
...files in ./foobar...
$ ./myscript --version
myscript/0.0.0 darwin-x64 node-v9.5.0
$ ./myscript --help
USAGE
  $ @oclif/core

OPTIONS
  -d, --dir=dir  [default: /Users/jdickey/src/github.com/oclif/core]
  --help         show CLI help
  --version      show CLI version

See the generator for all the options you can pass to the command.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.0%
  • Other 1.0%