Package Exports
- @oclif/core
- @oclif/core/flush
- @oclif/core/flush.js
- @oclif/core/handle
- @oclif/core/lib/errors/index.js
- @oclif/core/lib/help/command.js
- @oclif/core/lib/help/root.js
- @oclif/core/lib/help/util.js
- @oclif/core/lib/interfaces/index.js
- @oclif/core/lib/util.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@oclif/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@oclif/core
base library for oclif CLIs
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} = this.parse(LS)
let files = fs.readdirSync(flags.dir)
for (let f of files) {
this.log(f)
}
}
}
LS.run()
.catch(require('@oclif/errors/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.