alto-command
alto-clif base command
Last updated 19 days ago by bodawei .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install alto-command 
SYNC missed versions from official npm registry.

alto-command

Version License

About

This is a fork of @oclif/command. The reason for this fork is to change this to allow space-separated subcommands rather than the heroku-style colon delimited. This is a minimal change, which should allow this to be used with the rest of the @oclif/* system.

Note that this accepts both the heroku style and the space-delimited style at the moment.

Notes/Next steps

  • This hasn't been particularly heavily tested, at this moment.
  • Other parts of the @oclif/* system may need to be alto-ized
  • Would like to set up a "heroku" flag in the package hosting this one, and let that drive whether this does or does not accept colons.

Warning

Consider this situation. You have a command like this:

mycmd topic1 topic2 cmd arg  # that is, in heroku-land mycmd topic1:topic2:cmd arg

imagine you mis-type this:

mycmd topic1 topic2 arg

and your arg happens to have the value "cmd". Then this will execute the command when you might have expected an error (this is hardly a surprise in the land of command line interfaces where many things like this can happy, but worth pointing out as a "failure mode" to be aware of)

Name explanation

This is an alternate oclif, which is to say: "alt-oclif", which is to say "alto-clif".

Thanks

Thanks to the @oclif team and contributors. There are are lot of great ideas in oclif! Without them, of course, this package wouldn't exist!

Original README info, below

oclif base command

Version 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

  • 0.9.9                                ...           latest (19 days ago)

8 Versions

  • 0.9.9                                ...           19 days ago
  • 0.9.8                                ...           19 days ago
  • 0.9.7                                ...           7 months ago
  • 0.9.5                                ...           a year ago
  • 0.9.4                                ...           a year ago
  • 0.9.3                                ...           a year ago
  • 0.9.1                                ...           a year ago
  • 0.9.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 26
Dependencies (6)
Dev Dependencies (18)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |