@oclif/command
oclif base command
Last updated 5 days 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.13                                ...           latest (5 days ago)

60 Versions

  • 1.5.13                                ...           5 days ago
  • 1.5.12                                ...           a month ago
  • 1.5.11                                ...           2 months ago
  • 1.5.10                                ...           2 months ago
  • 1.5.8                                ...           4 months ago
  • 1.5.6                                ...           5 months ago
  • 1.5.5                                ...           5 months ago
  • 1.5.4                                ...           6 months ago
  • 1.5.3                                ...           6 months ago
  • 1.5.2                                ...           7 months ago
  • 1.5.1                                ...           7 months ago
  • 1.5.0                                ...           8 months ago
  • 1.4.36                                ...           9 months ago
  • 1.4.35                                ...           9 months ago
  • 1.4.34                                ...           10 months ago
  • 1.4.33                                ...           10 months 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                                ...           a year ago
  • 1.4.13                                ...           a year ago
  • 1.4.12                                ...           a year ago
  • 1.4.11                                ...           a year ago
  • 1.4.10                                ...           a year ago
  • 1.4.9                                ...           a year ago
  • 1.4.8                                ...           a year ago
  • 1.4.7                                ...           a year ago
  • 1.4.6                                ...           a year ago
  • 1.4.5                                ...           a year ago
  • 1.4.4                                ...           a year ago
  • 1.4.3                                ...           a year ago
  • 1.4.2                                ...           a year ago
  • 1.4.1                                ...           a year ago
  • 1.4.0                                ...           a year ago
  • 1.3.3                                ...           a year ago
  • 1.3.2                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.25                                ...           a year ago
  • 1.2.24                                ...           a year ago
  • 1.2.23                                ...           a year ago
  • 1.2.22                                ...           a year ago
  • 1.2.21                                ...           a year ago
  • 1.2.20                                ...           a year ago
  • 1.2.19                                ...           a year ago
Downloads
Today 4
This Week 345
This Month 646
Last Day 8
Last Week 99
Last Month 5,521
Dependencies (4)
Dev Dependencies (17)
Dependents (757)

Copyright 2014 - 2016 © taobao.org |