Skip to content

Commit

Permalink
chore: update docs [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Oct 26, 2021
1 parent 15d73bf commit d48b0b1
Showing 1 changed file with 59 additions and 3 deletions.
62 changes: 59 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,64 @@
base library for oclif CLIs

[![Version](https://img.shields.io/npm/v/@oclif/core.svg)](https://npmjs.org/package/@oclif/core)
[![CircleCI](https://circleci.com/gh/oclif/core/tree/master.svg?style=svg)](https://circleci.com/gh/oclif/core/tree/master)
[![CircleCI](https://circleci.com/gh/oclif/core/tree/main.svg?style=svg)](https://circleci.com/gh/oclif/core/tree/main)
[![Downloads/week](https://img.shields.io/npm/dw/@oclif/core.svg)](https://npmjs.org/package/@oclif/core)
[![License](https://img.shields.io/npm/l/@oclif/core.svg)](https://github.com/oclif/core/blob/master/package.json)
[![License](https://img.shields.io/npm/l/@oclif/core.svg)](https://github.com/oclif/core/blob/main/package.json)

Docs coming soon...

Usage
=====

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

**TypeScript**
```js
#!/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:

```sh-session
$ ./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](https://github.com/oclif/oclif) for all the options you can pass to the command.

0 comments on commit d48b0b1

Please sign in to comment.