Return output in custom format
Opened this issue · 6 comments
Is your feature request related to a problem? Please describe.
It would be great to have commands output in custom formats, let's say in json, or csv, which would allow me to use it in custom CI tools
Describe the solution you'd like
acquiacli domain:list prod:sitename test --format=json
This would output the domains in a json format instead of the current fancy table output.
It would be an out of the box alternative to drush ac-domain-list --format=export
Describe alternatives you've considered
Custom php code to gather info from cloud api v2 using typhonius/acquia-php-sdk-v2
Additional context
Add any other context or screenshots about the feature request here.
Interesting idea. I'd probably want to have some kind of formatter class for outputs here so they could be overridden globally. Do you have an example of the data structure that would be of benefit here?
No specific example for the data structure... i'd say fit the data in a key/value format
I found this thread searching for the same option. In my case, I'm trying to retrieve a list of databases via acquiacli database:list prod:sitename
to script the creation of sites.php for a multisite installation. Having the ability to return json/csv results in this case would be helpful.
The best way to implement this would be through the use of a command line option e.g. --format=json
. What I'm not sure about is whether this should be implemented as a trait or as an entirely separate class. I may even look at how the Symfony Table component is made and try and replicate with a JSON output component.
I've just pushed some code into a new branch #129 to test out how this could work. If you could test this out to make sure it matches what you're expecting (domain:info
, domain:list
, and account
) then I can change some more commands over.
so far, so good
~/Sites/devops/acquia/typhonius/acquia_cli : outputformats $ ./bin/acquiacli domain:list prod:mysitename dev --format=json
PHP Notice: Trying to get property 'id' of non-object in /Users/lnunes/Sites/devops/acquia/typhonius/acquia_cli/src/Cli/CloudApi.php on line 73
Notice: Trying to get property 'id' of non-object in /Users/lnunes/Sites/devops/acquia/typhonius/acquia_cli/src/Cli/CloudApi.php on line 73
{"0":{"hostname":"mysitenamedev.prod.acquia-sites.com","flags":{"default":true,"active":false,"uptime":false,"wildcard":false},"ip_addresses":null,"cnames":null,"environment":{"id":"999999999999999999","name":"dev"},"links":{"self":{"href":"https:\/\/cloud.acquia.com\/api\/environments\/999999999999999999\/domains\/mysitenamedev.prod.acquia-sites.com"},"status":{"href":"https:\/\/cloud.acquia.com\/api\/environments\/999999999999999999\/domains\/mysitenamedev.prod.acquia-sites.com\/status"}}},"1":{"hostname":"mysitename-dev.domain.io","flags":{"default":false,"active":true,"uptime":false,"wildcard":false},"ip_addresses":null,"cnames":null,"environment":{"id":"999999999999999999","name":"dev"},"links":{"self":{"href":"https:\/\/cloud.acquia.com\/api\/environments\/999999999999999999\/domains\/mysitename-dev.domain.io"},"status":{"href":"https:\/\/cloud.acquia.com\/api\/environments\/999999999999999999\/domains\/mysitename-dev.domain.io\/status"}}}}