When you execute Acquia CLI commands invoking a Cloud Platform API endpoint, the endpoint returns a machine-readable JSON response.
Acquia recommends you to use the following open source tools to navigate the JSON response:
jq: Lightweight and flexible JSON processor. Acquia recommends you to read the manual to discover its possibilities.
jid: JSON incremental digger
jtbl: Print JSON and JSON Lines data as a table
The following are the examples where Acquia CLI leverages these tools to be more productive and achieve typical use cases:
Use the limit
filter in jq
to return a subset of the results:
$ acli api:applications:notification-list myapp | jq '[limit(3;.[] | {event, completed_at})]'
[
{
"event": "DatabaseBackupDownloaded",
"completed_at": "2021-02-24T16:13:37+00:00"
},
{
"event": "RemoteIdeCreatedEvent",
"completed_at": "2021-02-24T13:22:03+00:00"
},
{
"event": "DatabaseBackupDownloaded",
"completed_at": "2021-02-23T18:23:29+00:00"
}
]
Pass a select
query to search for a partial match in the JSON output:
$ acli api:applications:list | jq '.[] | select(.hosting.id | contains ("thomas"))'
{
"id": 111241,
"uuid": "da76k877-fc7f-bcf4-2523-c801f469b9dc",
"name": "thomas",
"hosting": {
"type": "ace",
"id": "prod:thomas"
},
"subscription": {
"uuid": "1054c7fc-8954-4e52-b132-a4f5bc3a7d16",
"name": "Thomas - Sandbox"
},
"organization": {
"uuid": "d29ej812-7c03-11e4-b588-22000b04072f",
"name": "My Drupal 9 Application"
},
"flags": {
"remote_admin": false
},
"status": "normal",
"type": "drupal",
"platform": null,
"_links": {
"self": {
"href": "https://cloud.acquia.com/api/applications/da76k877-fc7f-bcf4-2523-c801f469b9dc"
},
"parent": {
"href": "https://cloud.acquia.com/api/applications"
}
},
"_embedded": {
"tags": []
}
}
Use jq
to filter out the JSON response:
$ acli api:applications:environment-list myapp | jq '.[].name'
"dev"
"prod"
"test"
"ra"
"ama"
Use jid
to scan through the JSON response until you find the desired result:
Use jtbl
to improve the readability of the JSON response. If your output
is not complex, pipe it to jtbl
to view a formatted table:
$ acli api:distributions:list | jq -c '.[] | {title,version}' | jtbl
title version
--------------------------------- ----------
Drupal 9 9.0.3
Acquia Connector 8.x-1.9
Apigee Developer Portal Kickstart 8.x-1.7
Commerce Kickstart 7.x-2.62
DKAN 7.x-1.15.4
govCMS 7.x-3.6
Open Atrium 7.x-2.69
OpenPublic 7.x-1.9
Thunder 8.x-2.9
Web Experience Toolkit 7.x-4.9
After you initiate the process of creating a database backup through Acquia CLI,
the system takes some time to complete the process. You cannot deploy your code or
perform other tasks until the process is completed. To wait until the system creates
the backup, use the app:task-wait
command:
acli app:task-wait "$(acli api:environments:database-backup-create myapp.dev my_db)"
The following are examples of other operations that you can perform with Acquia CLI:
To create a new Drupal application with the acli new
command:
Open Terminal on your local machine.
Run the acli new
command.
The system prompts you to choose a project template.
See the following example:
$ acli new
Acquia recommends most customers use acquia/drupal-recommended-project,
which includes useful utilities such as Acquia Connector.
acquia/drupal-minimal-project is the most minimal application that will
run on Cloud Platform.
Which starting project would you like to use?
[0] acquia/drupal-recommended-project
[1] acquia/drupal-minimal-project
> 1
Creating project. This may take a few minutes
Creating a "acquia/drupal-minimal-project" project at "./drupal"
...
New 💧Drupal project created in /tmp/drupal. 🎉
To define a script that runs before, or after any Acquia CLI command, add the
script to the root composer.json
file. Ensure that you follow the naming
pattern (pre|post)-acli-(command name with dashes)
. For example,
pre-acli-push-db
or post-acli-pull-files
. The script does not run if
you name it incorrectly. See the following examples:
"scripts": {
"pre-acli-pull-db": [
"echo \"I'm pulling the database now!\""
],
"post-acli-pull-db": [
"echo \"I'm done pulling the database!\""
],
}