Export the CLI config so that it can be consumed by other projects that may include this
Closed this issue · 2 comments
twilio-run does this and the serverless plugin for the CLI consumes it.
@dkundel I know you showed me where this is needed and the format you want it in, but that was a few weeks ago now. Can you point me to where this is used and what would be useful to export for your code, please?
Here is an example:
https://github.com/twilio-labs/twilio-run/blob/ts/src/commands/start.ts
Basically you need to export the following properties:
type Module {
// Usage description
describe: string;
// list of ways to call the command
command: string[];
// defines the different flags and their types
cliConfig: CliConfig;
// handler that receives the actual flags
handler(argv: Flags): Promise<void>
}Here's the definition of CliOptions: https://github.com/twilio-labs/twilio-run/blob/ts/src/commands/types.ts#L3
Here you can see how I'm consuming it compared to how I'm consuming yours:
https://github.com/twilio-labs/plugin-serverless/blob/master/src/commands/serverless/start.js
https://github.com/twilio-labs/plugin-serverless/blob/master/src/commands/serverless/init.js
Let me know if this helps. You can see in the respective commands folders in both directories how they map to each other.
I'm using yargs for the twilio-cli. I wrote a helper function that basically takes the flags that are defined in cliConfig.options and turns them into flags for oclif so that the two are automatically in sync. https://github.com/twilio-labs/plugin-serverless/blob/master/src/commands/serverless/start.js#L36-L38