Progress Indicator for DOCTL Commands

I’m building a script that automatically will shutdown a droplet before it creates a snapshot, and then powers it back on.

The snapshot takes time to complete, but I think it would be great to see progress indicator. Any ideas on how to do this?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

When scripting with doctl you can pass the --wait flag to Droplet “action” commands in order to block until the action has completed. For example:

doctl compute droplet-action power-off --wait <droplet-id>

Unfortunately, as the API does not report back detailed progress information, creating an accurate progress indicator would not be possible. You can vote for this feature request on to show your support for that feature.

There are a number of different approaches you could take to add a spinner to indicate that the script is still working. This blog post is a good explanation of how these tend to work.