This library been replaced by @oclif/core and is no longer maintained
oclif base command
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.
Without the generator, you can create a simple CLI like this:
TypeScript
#!/usr/bin/env ts-node
import*asfsfrom'fs'import{Command,flags}from'@oclif/command'classLSextendsCommand{staticflags={version: flags.version(),help: flags.help(),// run with --dir= or -d=dir: flags.string({char: 'd',default: process.cwd(),}),}asyncrun(){const{flags}=this.parse(LS)letfiles=fs.readdirSync(flags.dir)for(letfoffiles){this.log(f)}}}LS.run().catch(require('@oclif/errors/handle'))JavaScript
#!/usr/bin/env node
constfs=require('fs')const{Command, flags}=require('@oclif/command')classLSextendsCommand{asyncrun(){const{flags}=this.parse(LS)letfiles=fs.readdirSync(flags.dir)for(letfoffiles){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 --versionmyscript/0.0.0 darwin-x64 node-v9.5.0
$ ./myscript --helpUSAGE $ @oclif/commandOPTIONS -d, --dir=dir [default: /Users/jdickey/src/github.com/oclif/command] --help show CLI help --version show CLI versionSee the generator for all the options you can pass to the command.