summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/lib.rs b/src/lib.rs
index bc5a794..12e0cdf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -29,6 +29,7 @@ pub mod builder;
pub mod rep;
pub mod transport;
pub mod errors;
+pub mod tty;
mod tarball;
@@ -50,6 +51,7 @@ use rep::{NetworkDetails as NetworkInfo, NetworkCreateInfo};
use rep::{Output, PullInfo, Change, ContainerCreateInfo, ContainerDetails,
Container as ContainerRep, Event, Exit, History, ImageDetails, Info, SearchResult,
Stats, Status, Top, Version};
+use tty::Tty;
use rustc_serialize::json::{self, Json};
use std::borrow::Cow;
use std::env::{self, VarError};
@@ -419,26 +421,27 @@ impl<'a, 'b> Container<'a, 'b> {
}
/// Exec the specified command in the container
- pub fn exec(&self, opts: &ExecContainerOptions) -> Result<()> {
+ pub fn exec(&self, opts: &ExecContainerOptions) -> Result<Tty> {
let data = try!(opts.serialize());
let mut bytes = data.as_bytes();
match self.docker
- .post(&format!("/containers/{}/exec", self.id)[..],
- Some((&mut bytes, ContentType::json()))) {
+ .post(&format!("/containers/{}/exec", self.id)[..],
+ Some((&mut bytes, ContentType::json()))) {
Err(e) => Err(e),
Ok(res) => {
let data = "{}";
let mut bytes = data.as_bytes();
self.docker
- .post(&format!("/exec/{}/start",
- Json::from_str(res.as_str())
- .unwrap()
- .search("Id")
- .unwrap()
- .as_string()
- .unwrap())[..],
- Some((&mut bytes, ContentType::json())))
- .map(|_| ())
+ .stream_post(&format!("/exec/{}/start",
+ Json::from_str(res.as_str())
+ .unwrap()
+ .search("Id")
+ .unwrap()
+ .as_string()
+ .unwrap())
+ [..],
+ Some((&mut bytes, ContentType::json())))
+ .map(|stream| Tty::new(stream))
}
}
}