-
Notifications
You must be signed in to change notification settings - Fork 47
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
CLI-822: Add --task-wait option to API commands #1829
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1829 +/- ##
=========================================
Coverage 92.64% 92.64%
- Complexity 1833 1837 +4
=========================================
Files 123 123
Lines 6946 6952 +6
=========================================
+ Hits 6435 6441 +6
Misses 511 511 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/1829/acli.phar
|
@eporama can you take this for a spin and let me know what you think? Right now you'll get output like this:
It's a little weird because API commands normally return JSON output. If you add And then the command exit code becomes the notification status (success/failure) rather than the initial API response (202/40x). That seems intuitive to me but I'm not sure if it needs to be documented. |
I agree that the output is a bit odd with the mixture of json and command. Personally, I don't need to see the JSON of a successfully submitted task, but would like to see the failure messages when the submission fails:
I think we should trap for the error and
seems like our problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easier to read 👍
$ ./acli.phar api:environments:database-backup-create --task-wait eeepeterson.swat eeepeterson
✔ Waiting for task f735b1fc-fc14-44fc-bcd2-5767d7e09ccd to complete
[OK] The task with notification uuid f735b1fc-fc14-44fc-bcd2-5767d7e09ccd completed
Progress: 100
Completed: Tue Nov 19 16:09:46 UTC 2024
Task type: Database backup created
Duration: 28 seconds
I wonder if it would be possible to have a different wait mechanism for scripting which doesn't output the spinner and just finishes with the json of the notification once it's complete. --non-interactive
or --format=json
or something? Happy to have that be a follow up as well if we want to get this out.
Looks like the error message is more concise as well 👍
$ ./acli.phar api:environments:database-backup-create --task-wait eeepeterson.swat eeepeterson3
{
"error": "validation_failed",
"message": {
"database": "The database does not exist in this environment."
}
}
The spinner still behaves gracefully in a non-interactive environment and you could just check the exit code (ignore the output) if that's all you care about. Maybe take this for a spin and if you still think we need different non-interactive behavior we can talk. |
Motivation
Fixes CLI-822
Proposed changes
Add a
--task-wait
option to API commands that return a notification which will cause the command to wait for the notification to complete.Testing steps
./bin/acli ckc
--task-wait
option:wacli help api:environments:code-switch
--task-wait
option, see it behaves like before:wacli api:environments:code-switch pipelinesvalidation2.dev master
--task-wait
option, see it still fails:wacli api:environments:database-backup-create --task-wait eeepeterson.dev eeepeterson3
--task-wait
, see it waits for the task to complete:wacli api:environments:code-switch pipelinesvalidation2.dev master --task-wait