summaryrefslogtreecommitdiff
path: root/bin/core/imag-store
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-02-14 17:27:54 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-02-19 10:40:26 +0100
commit88d21375b9bd10c3d4e4a3a9203ec697a0f398a5 (patch)
treeda0e6f5e00ea07f897912928ecb73d54fdcf1cd0 /bin/core/imag-store
parent256bc47222df84a04895bce496d7edb588d992e0 (diff)
downloadimag-88d21375b9bd10c3d4e4a3a9203ec697a0f398a5.zip
imag-88d21375b9bd10c3d4e4a3a9203ec697a0f398a5.tar.gz
Refactor "imag store ids" command to not panic on broken pipe
Diffstat (limited to 'bin/core/imag-store')
-rw-r--r--bin/core/imag-store/src/ids.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/bin/core/imag-store/src/ids.rs b/bin/core/imag-store/src/ids.rs
index 02b7960..d64659c 100644
--- a/bin/core/imag-store/src/ids.rs
+++ b/bin/core/imag-store/src/ids.rs
@@ -17,14 +17,18 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
+use std::io::Write;
+
use libimagrt::runtime::Runtime;
use libimagerror::trace::*;
+use libimagerror::io::ToExitCode;
+use libimagerror::exit::ExitUnwrap;
pub fn ids(rt: &Runtime) {
let full = rt.cli().subcommand_matches("ids").unwrap() //secured by main
.is_present("full");
let base = rt.store().path();
- let _ :Vec<_> = rt
+ let _ = rt
.store()
.entries()
.map_err_trace_exit_unwrap(1)
@@ -35,7 +39,9 @@ pub fn ids(rt: &Runtime) {
})
.map(|i| i.to_str())
.map(|elem| elem.map_err_trace_exit_unwrap(1))
- .map(|i| println!("{}", i))
- .collect();
+ .map(|i| writeln!(::std::io::stdout(), "{}", i))
+ .collect::<Result<Vec<()>, ::std::io::Error>>()
+ .to_exit_code()
+ .unwrap_or_exit();
}