summaryrefslogtreecommitdiffstats
path: root/examples/imagepull.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/imagepull.rs')
-rw-r--r--examples/imagepull.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/examples/imagepull.rs b/examples/imagepull.rs
index d460a41..1039080 100644
--- a/examples/imagepull.rs
+++ b/examples/imagepull.rs
@@ -1,17 +1,22 @@
extern crate shiplift;
+extern crate tokio;
use shiplift::{Docker, PullOptions};
use std::env;
+use tokio::prelude::{Future, Stream};
fn main() {
let docker = Docker::new();
- if let Some(img) = env::args().nth(1) {
- let image = docker
- .images()
- .pull(&PullOptions::builder().image(img).build())
- .unwrap();
- for output in image {
+ let img = env::args()
+ .nth(1)
+ .expect("You need to specify an image name");
+ let fut = docker
+ .images()
+ .pull(&PullOptions::builder().image(img).build())
+ .for_each(|output| {
println!("{:?}", output);
- }
- }
+ Ok(())
+ })
+ .map_err(|e| eprintln!("Error: {}", e));
+ tokio::run(fut);
}