twilio-labs / serverless-toolkit

CLI tool to develop, debug and deploy Twilio Functions
https://www.twilio.com/docs/labs/serverless-toolkit
MIT License
114 stars 59 forks source link

Implement machine readable output format #62

Open stefanjudis opened 5 years ago

stefanjudis commented 5 years ago

I'm currently writing an automation shell script that buys a number, creates a sync service, and deploys a function. These deployed function should be used by the just bought number. Unfortunately, I didn't see a way to get the command response in an easy machine readable format.

The twilio CLI provides the command option -o=json for several other commands. This option allows to get the command response in JSON and thus in a machine readable format. It makes it possible to re-use values and to write advanced scripts. It would be great to have this option in the Twilio Serverless CLI plugin, too.

As the CLI is only a wrapper around twilio-run I thought that it's best to open the issue here first. :)

What I'm looking for is something as follows:

# in the Twilio CLI
$ twilio serverless.deploy -o=json

# and in twilio-run
$ twilio-run deploy --output=json

Is this something you'd be up for?

dkundel commented 5 years ago

This is definitely on the roadmap for post SIGNAL. Thanks for filing this.

philnash commented 4 years ago

OK, so I've been working on this and I got quite a way into it before getting confused 😄

The commands list, list-templates, deploy, activate and logs all call off to APIs and have JSON results.

The commands new and start do not do that and don't really have an obvious return data. start isn't really a command that would be used by a machine but new is used by create-twilio-function.

So far, the work is ongoing on my json-output branch. I've added a output-format option to the BaseCliFlags but now I realise that the start and new commands don't necessarily need a JSON output, so perhaps it shouldn't be in BaseCliFlags.

So, to my questions:

Should the start and new commands have the --output-format flag as an option at all?

Should those two have another flag/option which silences their output so that other programs can use them without them making a mess over the terminal (e.g. see the test output of create-twilio-function)?

Or should I just leave the start and new commands alone for now?