1.8.20 • Published 25 days ago

@oclif/command v1.8.20

Weekly downloads
1,358,969
License
MIT
Repository
github
Last release
25 days ago

@oclif/command

This library been replaced by @oclif/core and is now in maintenance mode. We will only consider PRs that address security concerns.

oclif base command

Version CircleCI Appveyor CI Known Vulnerabilities Downloads/week License

This is about half of the main codebase for oclif. The other half lives in @oclif/config. This can be used directly, but it probably makes more sense to build your CLI with the generator.

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/command'

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'))

JavaScript

#!/usr/bin/env node

const fs = require('fs')
const {Command, flags} = require('@oclif/command')

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

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

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/command

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

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

1.8.20

25 days ago

1.8.18

2 months ago

1.8.19

1 month ago

1.8.2

1 year ago

1.8.1

1 year ago

1.8.9

12 months ago

1.8.10

12 months ago

1.8.8

12 months ago

1.8.11

12 months ago

1.8.7

12 months ago

1.8.12

12 months ago

1.8.6

1 year ago

1.8.13

12 months ago

1.8.5

1 year ago

1.8.14

12 months ago

1.8.4

1 year ago

1.8.15

12 months ago

1.8.3

1 year ago

1.8.16

12 months ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.6.0-rc1.1

3 years ago

1.6.0-rc1.2

3 years ago

1.6.0-rc1

3 years ago

1.5.20

3 years ago

1.5.19

3 years ago

1.5.18

3 years ago

1.5.17

3 years ago

1.5.16

3 years ago

1.5.15

3 years ago

1.5.14

4 years ago

1.5.13

4 years ago

1.5.12

4 years ago

1.5.11

4 years ago

1.5.10

4 years ago

1.5.8

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.36

4 years ago

1.4.35

4 years ago

1.4.34

4 years ago

1.4.33

4 years ago

1.4.32

5 years ago

1.4.31

5 years ago

1.4.30

5 years ago

1.4.29

5 years ago

1.4.28

5 years ago

1.4.27

5 years ago

1.4.26

5 years ago

1.4.25

5 years ago

1.4.24

5 years ago

1.4.23

5 years ago

1.4.22

5 years ago

1.4.21

5 years ago

1.4.20

5 years ago

1.4.19

5 years ago

1.4.18

5 years ago

1.4.17

5 years ago

1.4.16

5 years ago

1.4.15

5 years ago

1.4.14

5 years ago

1.4.13

5 years ago

1.4.12

5 years ago

1.4.11

5 years ago

1.4.10

5 years ago

1.4.9

5 years ago

1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.25

5 years ago

1.2.24

5 years ago

1.2.23

5 years ago

1.2.22

5 years ago

1.2.21

5 years ago

1.2.20

5 years ago

1.2.19

5 years ago