Summary: Provides some really nice helpers and generators for multi command CLIs, including test helpers and all sorts of output niceties. This should make it quite easy for us to add additional sub-commands for bundling, publishing and keeping docs for all of it. Heroku maintains this and provides some excellent docs, too: https://oclif.io/ My only complaint is that it's class-based but that's effectively only the way to declare new commands and enforces a set of required/static properties on it. Reviewed By: nikoant Differential Revision: D19970293 fbshipit-source-id: 4228e502198c6fd376854a90ed2f01da29e96bc2
41 lines
996 B
TypeScript
41 lines
996 B
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {Command, flags} from '@oclif/command';
|
|
|
|
export default class Hello extends Command {
|
|
static description = 'describe the command here';
|
|
|
|
static examples = [
|
|
`$ flipper-pkg hello
|
|
hello world from ./src/hello.ts!
|
|
`,
|
|
];
|
|
|
|
static flags = {
|
|
help: flags.help({char: 'h'}),
|
|
// flag with a value (-n, --name=VALUE)
|
|
name: flags.string({char: 'n', description: 'name to print'}),
|
|
// flag with no value (-f, --force)
|
|
force: flags.boolean({char: 'f'}),
|
|
};
|
|
|
|
static args = [{name: 'file'}];
|
|
|
|
async run() {
|
|
const {args, flags} = this.parse(Hello);
|
|
|
|
const name = flags.name || 'world';
|
|
this.log(`hello ${name} from ./src/commands/hello.ts`);
|
|
if (args.file && flags.force) {
|
|
this.log(`you input --force and --file: ${args.file}`);
|
|
}
|
|
}
|
|
}
|