summaryrefslogtreecommitdiffstats
path: root/examples/networkconnect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/networkconnect.rs')
-rw-r--r--examples/networkconnect.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/networkconnect.rs b/examples/networkconnect.rs
index 0cfc8fc..a04db63 100644
--- a/examples/networkconnect.rs
+++ b/examples/networkconnect.rs
@@ -1,18 +1,20 @@
use shiplift::{ContainerConnectionOptions, Docker};
use std::env;
-use tokio::prelude::Future;
-fn main() {
+#[tokio::main]
+async fn main() {
let docker = Docker::new();
let networks = docker.networks();
+
match (env::args().nth(1), env::args().nth(2)) {
(Some(container_id), Some(network_id)) => {
- let fut = networks
+ if let Err(e) = networks
.get(&network_id)
.connect(&ContainerConnectionOptions::builder(&container_id).build())
- .map(|v| println!("{:?}", v))
- .map_err(|e| eprintln!("Error: {}", e));
- tokio::run(fut);
+ .await
+ {
+ eprintln!("Error: {}", e)
+ }
}
_ => eprintln!("please provide a container_id and network_id"),
}