The twilio-cli is built using the Open CLI Framework (oclif). It is using the "Multi-command" project type. You will specifically want to review the docs:
Start by cloning this repo of an example plugin.
Commands go in the src/commands
folder and should inherit from one of our command base classes.
Clone the main CLI repo (this repo) and set it up.
"Install" the plugin referencing your plugin's local development folder like so:
./bin/run plugins:link ../plugin-<my-spectacular-plugin>
Run this command from the CLI folder. This assumes the CLI and your plugin folders are siblings of each other (perhaps in a ~/Projects
folder).
Now, you can run your plugin command from the CLI:
./bin/run my-new-topic:my-new-command --help
Inherit from TwilioClientCommand
if your command will need to make Twilio API calls. You will be provided with a this.twilioClient
to make API calls using the Node.js helper library for Twilio. The client object will already have the necessary credentials and account SID. Just start calling the API. You are also given an this.httpClient
to make requests to other API's, but you'll need to manage any necessary credentials yourself.
Inherit from TwilioBaseCommand
if your command doesn't need to make any API calls.