@oclif/command
oclif base command
Last updated 2 months ago by rasphilco .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @oclif/command 
SYNC missed versions from official npm registry.

@oclif/command

oclif base command

Version CircleCI Appveyor CI Codecov 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.

Current Tags

  • 1.5.19                                ...           latest (2 months ago)

66 Versions

  • 1.5.19                                ...           2 months ago
  • 1.5.18                                ...           3 months ago
  • 1.5.17                                ...           3 months ago
  • 1.5.16                                ...           3 months ago
  • 1.5.15                                ...           4 months ago
  • 1.5.14                                ...           5 months ago
  • 1.5.13                                ...           6 months ago
  • 1.5.12                                ...           7 months ago
  • 1.5.11                                ...           8 months ago
  • 1.5.10                                ...           8 months ago
  • 1.5.8                                ...           10 months ago
  • 1.5.6                                ...           a year ago
  • 1.5.5                                ...           a year ago
  • 1.5.4                                ...           a year ago
  • 1.5.3                                ...           a year ago
  • 1.5.2                                ...           a year ago
  • 1.5.1                                ...           a year ago
  • 1.5.0                                ...           a year ago
  • 1.4.36                                ...           a year ago
  • 1.4.35                                ...           a year ago
  • 1.4.34                                ...           a year ago
  • 1.4.33                                ...           a year ago
  • 1.4.32                                ...           a year ago
  • 1.4.31                                ...           a year ago
  • 1.4.29                                ...           a year ago
  • 1.4.30                                ...           a year ago
  • 1.4.28                                ...           a year ago
  • 1.4.27                                ...           a year ago
  • 1.4.26                                ...           a year ago
  • 1.4.25                                ...           a year ago
  • 1.4.24                                ...           a year ago
  • 1.4.23                                ...           a year ago
  • 1.4.22                                ...           a year ago
  • 1.4.21                                ...           a year ago
  • 1.4.20                                ...           a year ago
  • 1.4.19                                ...           a year ago
  • 1.4.18                                ...           a year ago
  • 1.4.17                                ...           a year ago
  • 1.4.16                                ...           a year ago
  • 1.4.15                                ...           a year ago
  • 1.4.14                                ...           2 years ago
  • 1.4.13                                ...           2 years ago
  • 1.4.12                                ...           2 years ago
  • 1.4.11                                ...           2 years ago
  • 1.4.10                                ...           2 years ago
  • 1.4.9                                ...           2 years ago
  • 1.4.8                                ...           2 years ago
  • 1.4.7                                ...           2 years ago
  • 1.4.6                                ...           2 years ago
  • 1.4.5                                ...           2 years ago
  • 1.4.4                                ...           2 years ago
  • 1.4.3                                ...           2 years ago
  • 1.4.2                                ...           2 years ago
  • 1.4.1                                ...           2 years ago
  • 1.4.0                                ...           2 years ago
  • 1.3.3                                ...           2 years ago
  • 1.3.2                                ...           2 years ago
  • 1.3.1                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.25                                ...           2 years ago
  • 1.2.24                                ...           2 years ago
  • 1.2.23                                ...           2 years ago
  • 1.2.22                                ...           2 years ago
  • 1.2.21                                ...           2 years ago
  • 1.2.20                                ...           2 years ago
  • 1.2.19                                ...           2 years ago
Downloads
Today 1,498
This Week 3,621
This Month 11,854
Last Day 2,123
Last Week 7,262
Last Month 2,643
Dependencies (6)
Dev Dependencies (15)
Dependents (1353)

Copyright 2014 - 2016 © taobao.org |