summaryrefslogtreecommitdiff
path: root/bin/core/imag-store
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-02-14 23:45:28 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-02-19 11:14:19 +0100
commit36e511d39bf3302331a7f0c7b2de0286c6c94848 (patch)
tree5bdaa61528b7ef552dd365b2474f04bc13a60ae3 /bin/core/imag-store
parent380aeccdc7483f349e491620fbe62b1bfac919ec (diff)
downloadimag-36e511d39bf3302331a7f0c7b2de0286c6c94848.zip
imag-36e511d39bf3302331a7f0c7b2de0286c6c94848.tar.gz
Fix broken pipe panics
Diffstat (limited to 'bin/core/imag-store')
-rw-r--r--bin/core/imag-store/src/retrieve.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/bin/core/imag-store/src/retrieve.rs b/bin/core/imag-store/src/retrieve.rs
index 1ebeeb7..20dc100 100644
--- a/bin/core/imag-store/src/retrieve.rs
+++ b/bin/core/imag-store/src/retrieve.rs
@@ -18,6 +18,7 @@
//
use std::path::PathBuf;
+use std::io::Write;
use clap::ArgMatches;
@@ -25,6 +26,8 @@ use libimagstore::store::FileLockEntry;
use libimagstore::storeid::StoreId;
use libimagrt::runtime::Runtime;
use libimagerror::trace::MapErrTrace;
+use libimagerror::io::ToExitCode;
+use libimagerror::exit::ExitUnwrap;
use libimagutil::debug_result::*;
pub fn retrieve(rt: &Runtime) {
@@ -48,9 +51,13 @@ pub fn retrieve(rt: &Runtime) {
}
pub fn print_entry(rt: &Runtime, scmd: &ArgMatches, e: FileLockEntry) {
+ let mut out = ::std::io::stdout();
+
if do_print_raw(scmd) {
debug!("Printing raw content...");
- println!("{}", e.to_str());
+ let _ = writeln!(out, "{}", e.to_str())
+ .to_exit_code()
+ .unwrap_or_exit();
} else if do_filter(scmd) {
debug!("Filtering...");
warn!("Filtering via header specs is currently now supported.");
@@ -67,13 +74,17 @@ pub fn print_entry(rt: &Runtime, scmd: &ArgMatches, e: FileLockEntry) {
unimplemented!()
} else {
debug!("Printing header as TOML...");
- println!("{}", e.get_header())
+ let _ = writeln!(out, "{}", e.get_header())
+ .to_exit_code()
+ .unwrap_or_exit();
}
}
if do_print_content(scmd) {
debug!("Printing content...");
- println!("{}", e.get_content());
+ let _ = writeln!(out, "{}", e.get_content())
+ .to_exit_code()
+ .unwrap_or_exit();
}
}