Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return output in custom format #96

Open
lnunesbr opened this issue Jun 2, 2020 · 6 comments
Open

Return output in custom format #96

lnunesbr opened this issue Jun 2, 2020 · 6 comments

Comments

@lnunesbr
Copy link

lnunesbr commented Jun 2, 2020

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.

@typhonius
Copy link
Owner

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?

@lnunesbr
Copy link
Author

lnunesbr commented Jun 4, 2020

No specific example for the data structure... i'd say fit the data in a key/value format

@willjackson
Copy link

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.

@typhonius
Copy link
Owner

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.

@typhonius
Copy link
Owner

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.

@lnunesbr
Copy link
Author

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"}}}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants