Use output stream from Runtime::stdout()

This commit is contained in:
Matthias Beyer 2018-02-26 22:57:17 +01:00
parent c18c0bbbe4
commit 50461b839a
24 changed files with 55 additions and 87 deletions

View file

@ -135,7 +135,6 @@ fn remove(rt: &Runtime) {
} }
fn list(rt: &Runtime) { fn list(rt: &Runtime) {
let mut out = ::std::io::stdout();
let scmd = rt.cli().subcommand_matches("list").unwrap(); // safed by clap let scmd = rt.cli().subcommand_matches("list").unwrap(); // safed by clap
let with_text = scmd.is_present("list-with-text"); let with_text = scmd.is_present("list-with-text");
match scmd.value_of("entry").map(PathBuf::from) { match scmd.value_of("entry").map(PathBuf::from) {
@ -150,7 +149,7 @@ fn list(rt: &Runtime) {
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.enumerate() .enumerate()
.map(|(i, a)| { .map(|(i, a)| {
list_annotation(&mut out, i, a.map_err_trace_exit_unwrap(1), with_text) list_annotation(&rt, i, a.map_err_trace_exit_unwrap(1), with_text)
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
} }
@ -163,22 +162,22 @@ fn list(rt: &Runtime) {
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.enumerate() .enumerate()
.map(|(i, a)| { .map(|(i, a)| {
list_annotation(&mut out, i, a.map_err_trace_exit_unwrap(1), with_text) list_annotation(&rt, i, a.map_err_trace_exit_unwrap(1), with_text)
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
} }
} }
} }
fn list_annotation<'a>(out: &mut Write, i: usize, a: FileLockEntry<'a>, with_text: bool) { fn list_annotation<'a>(rt: &Runtime, i: usize, a: FileLockEntry<'a>, with_text: bool) {
let _ = if with_text { let _ = if with_text {
writeln!(out, writeln!(rt.stdout(),
"--- {i: >5} | {id}\n{text}\n\n", "--- {i: >5} | {id}\n{text}\n\n",
i = i, i = i,
id = a.get_location(), id = a.get_location(),
text = a.get_content()) text = a.get_content())
} else { } else {
writeln!(out, "{: >5} | {}", i, a.get_location()) writeln!(rt.stdout(), "{: >5} | {}", i, a.get_location())
} }
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();

View file

@ -155,7 +155,7 @@ fn main() {
let n = diags.len(); let n = diags.len();
let mut out = ::std::io::stdout(); let mut out = rt.stdout();
let _ = writeln!(out, "imag version {}", env!("CARGO_PKG_VERSION")) let _ = writeln!(out, "imag version {}", env!("CARGO_PKG_VERSION"))
.to_exit_code() .to_exit_code()

View file

@ -144,10 +144,8 @@ fn remove(rt: &Runtime) {
}) })
.map_err_trace_exit_unwrap(1); // The parsing of the deleted values failed .map_err_trace_exit_unwrap(1); // The parsing of the deleted values failed
let mut out = ::std::io::stdout();
if scmd.is_present("print-removed") { if scmd.is_present("print-removed") {
let _ = writeln!(out, "{}", removed_value).to_exit_code().unwrap_or_exit(); let _ = writeln!(rt.stdout(), "{}", removed_value).to_exit_code().unwrap_or_exit();
} }
} }
@ -174,7 +172,6 @@ fn get(rt: &Runtime) {
exit(1) exit(1)
}); });
let mut out = ::std::io::stdout(); let _ = writeln!(rt.stdout(), "{}", value).to_exit_code().unwrap_or_exit();
let _ = writeln!(out, "{}", value).to_exit_code().unwrap_or_exit();
} }

View file

@ -44,6 +44,7 @@ use std::io::Write;
use regex::Regex; use regex::Regex;
use libimagrt::runtime::Runtime;
use libimagrt::setup::generate_runtime_setup; use libimagrt::setup::generate_runtime_setup;
use libimagstore::store::Entry; use libimagstore::store::Entry;
use libimagerror::trace::MapErrTrace; use libimagerror::trace::MapErrTrace;
@ -88,15 +89,13 @@ fn main() {
.into_get_iter() .into_get_iter()
.filter_map(|res| res.map_err_trace_exit_unwrap(1)) .filter_map(|res| res.map_err_trace_exit_unwrap(1))
.filter(|entry| pattern.is_match(entry.get_content())) .filter(|entry| pattern.is_match(entry.get_content()))
.map(|entry| show(&entry, &pattern, &opts, &mut count)) .map(|entry| show(&rt, &entry, &pattern, &opts, &mut count))
.count(); .count();
let mut out = ::std::io::stdout();
if opts.count { if opts.count {
let _ = writeln!(out, "{}", count).to_exit_code().unwrap_or_exit(); let _ = writeln!(rt.stdout(), "{}", count).to_exit_code().unwrap_or_exit();
} else if !opts.files_with_matches { } else if !opts.files_with_matches {
let _ = writeln!(out, "Processed {} files, {} matches, {} nonmatches", let _ = writeln!(rt.stdout(), "Processed {} files, {} matches, {} nonmatches",
overall_count, overall_count,
count, count,
overall_count - count) overall_count - count)
@ -105,24 +104,22 @@ fn main() {
} }
} }
fn show(e: &Entry, re: &Regex, opts: &Options, count: &mut usize) { fn show(rt: &Runtime, e: &Entry, re: &Regex, opts: &Options, count: &mut usize) {
let mut out = ::std::io::stdout();
if opts.files_with_matches { if opts.files_with_matches {
let _ = writeln!(out, "{}", e.get_location()).to_exit_code().unwrap_or_exit(); let _ = writeln!(rt.stdout(), "{}", e.get_location()).to_exit_code().unwrap_or_exit();
} else if opts.count { } else if opts.count {
*count += 1; *count += 1;
} else { } else {
let _ = writeln!(out, "{}:", e.get_location()).to_exit_code().unwrap_or_exit(); let _ = writeln!(rt.stdout(), "{}:", e.get_location()).to_exit_code().unwrap_or_exit();
for capture in re.captures_iter(e.get_content()) { for capture in re.captures_iter(e.get_content()) {
for mtch in capture.iter() { for mtch in capture.iter() {
if let Some(m) = mtch { if let Some(m) = mtch {
let _ = writeln!(out, " '{}'", m.as_str()).to_exit_code().unwrap_or_exit(); let _ = writeln!(rt.stdout(), " '{}'", m.as_str()).to_exit_code().unwrap_or_exit();
} }
} }
} }
let _ = writeln!(out, "").to_exit_code().unwrap_or_exit(); let _ = writeln!(rt.stdout(), "").to_exit_code().unwrap_or_exit();
} }
} }

View file

@ -60,13 +60,11 @@ fn main() {
"print all ids", "print all ids",
build_ui); build_ui);
let mut out = ::std::io::stdout();
rt.store() rt.store()
.entries() .entries()
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.for_each(|id| { .for_each(|id| {
let _ = writeln!(out, "{}", id.to_str().map_err_trace_exit_unwrap(1)) let _ = writeln!(rt.stdout(), "{}", id.to_str().map_err_trace_exit_unwrap(1))
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();
}) })

View file

@ -254,7 +254,6 @@ fn list_linkings(rt: &Runtime) {
.unwrap(); // safed by clap .unwrap(); // safed by clap
let list_externals = cmd.is_present("list-externals-too"); let list_externals = cmd.is_present("list-externals-too");
let mut out = ::std::io::stdout();
for entry in cmd.values_of("entries").unwrap() { // safed by clap for entry in cmd.values_of("entries").unwrap() { // safed by clap
match rt.store().get(PathBuf::from(entry)) { match rt.store().get(PathBuf::from(entry)) {
@ -268,7 +267,7 @@ fn list_linkings(rt: &Runtime) {
.ok(); .ok();
if let Some(link) = link { if let Some(link) = link {
let _ = writeln!(out, "{: <3}: {}", i, link) let _ = writeln!(rt.stdout(), "{: <3}: {}", i, link)
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();
i += 1; i += 1;
@ -284,7 +283,7 @@ fn list_linkings(rt: &Runtime) {
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.into_string(); .into_string();
let _ = writeln!(out, "{: <3}: {}", i, link) let _ = writeln!(rt.stdout(), "{: <3}: {}", i, link)
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();

View file

@ -51,11 +51,9 @@ pub fn retrieve(rt: &Runtime) {
} }
pub fn print_entry(rt: &Runtime, scmd: &ArgMatches, e: FileLockEntry) { pub fn print_entry(rt: &Runtime, scmd: &ArgMatches, e: FileLockEntry) {
let mut out = ::std::io::stdout();
if do_print_raw(scmd) { if do_print_raw(scmd) {
debug!("Printing raw content..."); debug!("Printing raw content...");
let _ = writeln!(out, "{}", e.to_str()) let _ = writeln!(rt.stdout(), "{}", e.to_str())
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();
} else if do_filter(scmd) { } else if do_filter(scmd) {
@ -74,7 +72,7 @@ pub fn print_entry(rt: &Runtime, scmd: &ArgMatches, e: FileLockEntry) {
unimplemented!() unimplemented!()
} else { } else {
debug!("Printing header as TOML..."); debug!("Printing header as TOML...");
let _ = writeln!(out, "{}", e.get_header()) let _ = writeln!(rt.stdout(), "{}", e.get_header())
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();
} }
@ -82,7 +80,7 @@ pub fn print_entry(rt: &Runtime, scmd: &ArgMatches, e: FileLockEntry) {
if do_print_content(scmd) { if do_print_content(scmd) {
debug!("Printing content..."); debug!("Printing content...");
let _ = writeln!(out, "{}", e.get_content()) let _ = writeln!(rt.stdout(), "{}", e.get_content())
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();
} }

View file

@ -164,11 +164,9 @@ fn list(id: PathBuf, rt: &Runtime) {
unimplemented!() unimplemented!()
} }
let mut out = ::std::io::stdout();
if line_out { if line_out {
for tag in &tags { for tag in &tags {
let _ = writeln!(out, "{}", tag) let _ = writeln!(rt.stdout(), "{}", tag)
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();
} }
@ -176,13 +174,13 @@ fn list(id: PathBuf, rt: &Runtime) {
if sepp_out { if sepp_out {
let sepp = scmd.value_of("sep").unwrap(); // we checked before let sepp = scmd.value_of("sep").unwrap(); // we checked before
let _ = writeln!(out, "{}", tags.join(sepp)) let _ = writeln!(rt.stdout(), "{}", tags.join(sepp))
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();
} }
if comm_out { if comm_out {
let _ = writeln!(out, "{}", tags.join(", ")) let _ = writeln!(rt.stdout(), "{}", tags.join(", "))
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();
} }

View file

@ -135,11 +135,10 @@ fn list(rt: &Runtime) {
.map_err_trace_exit_unwrap(1); .map_err_trace_exit_unwrap(1);
let links = collection.links(rt.store()).map_err_trace_exit_unwrap(1); let links = collection.links(rt.store()).map_err_trace_exit_unwrap(1);
let mut out = ::std::io::stdout();
debug!("Listing..."); debug!("Listing...");
for (i, link) in links.enumerate() { for (i, link) in links.enumerate() {
match link { match link {
Ok(link) => writeln!(out, "{: >3}: {}", i, link).to_exit_code().unwrap_or_exit(), Ok(link) => writeln!(rt.stdout(), "{: >3}: {}", i, link).to_exit_code().unwrap_or_exit(),
Err(e) => trace_error(&e) Err(e) => trace_error(&e)
} }
}; };

View file

@ -20,7 +20,6 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::process::exit; use std::process::exit;
use std::io::Write; use std::io::Write;
use std::io::stdout;
use std::path::PathBuf; use std::path::PathBuf;
use std::fs::OpenOptions; use std::fs::OpenOptions;
@ -96,7 +95,7 @@ pub fn create(rt: &Runtime) {
(Box::new(file), Some(fl)) (Box::new(file), Some(fl))
} else { } else {
(Box::new(stdout()), None) (Box::new(rt.stdout()), None)
} }
}; };

View file

@ -109,7 +109,6 @@ fn main() {
fn list(rt: &Runtime) { fn list(rt: &Runtime) {
let scmd = rt.cli().subcommand_matches("list").unwrap(); let scmd = rt.cli().subcommand_matches("list").unwrap();
let list_format = get_contact_print_format("contact.list_format", rt, &scmd); let list_format = get_contact_print_format("contact.list_format", rt, &scmd);
let mut out = ::std::io::stdout();
let _ = rt let _ = rt
.store() .store()
@ -144,7 +143,7 @@ fn list(rt: &Runtime) {
.map_err(CE::from) .map_err(CE::from)
.map_err_trace_exit_unwrap(1); .map_err_trace_exit_unwrap(1);
writeln!(out, "{}", s).to_exit_code().unwrap_or_exit() writeln!(rt.stdout(), "{}", s).to_exit_code().unwrap_or_exit()
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
} }

View file

@ -33,13 +33,11 @@ pub fn list(rt: &Runtime) {
let diaryname = get_diary_name(rt) let diaryname = get_diary_name(rt)
.unwrap_or_else(|| warn_exit("No diary selected. Use either the configuration file or the commandline option", 1)); .unwrap_or_else(|| warn_exit("No diary selected. Use either the configuration file or the commandline option", 1));
let mut out = ::std::io::stdout();
Diary::entries(rt.store(), &diaryname) Diary::entries(rt.store(), &diaryname)
.map_dbg_str("Ok") .map_dbg_str("Ok")
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.for_each(|id| { .for_each(|id| {
writeln!(out, "{}", id writeln!(rt.stdout(), "{}", id
.without_base() .without_base()
.to_str() .to_str()
.map_err_trace() .map_err_trace()

View file

@ -79,9 +79,8 @@ fn main() {
if rt.is_ok() { if rt.is_ok() {
rt.unwrap() rt.unwrap()
} else { } else {
let mut out = ::std::io::stdout(); let _ = writeln!(rt.stdout(), "Could not set up Runtime").to_exit_code().unwrap_or_exit();
let _ = writeln!(out, "Could not set up Runtime").to_exit_code().unwrap_or_exit(); let _ = writeln!(rt.stdout(), "{:?}", rt.err().unwrap()).to_exit_code().unwrap_or_exit();
let _ = writeln!(out, "{:?}", rt.err().unwrap()).to_exit_code().unwrap_or_exit();
exit(1); exit(1);
} }
}; };

View file

@ -332,8 +332,7 @@ fn today(rt: &Runtime, future: bool) {
} }
if !empty { if !empty {
let mut out = ::std::io::stdout(); let _ = table.print(&mut rt.stdout()).to_exit_code().unwrap_or_exit();
let _ = table.print(&mut out).to_exit_code().unwrap_or_exit();
} }
} }
} }
@ -388,8 +387,7 @@ fn list(rt: &Runtime) {
}); });
if !empty { if !empty {
let mut out = ::std::io::stdout(); let _ = table.print(&mut rt.stdout()).to_exit_code().unwrap_or_exit();
let _ = table.print(&mut out).to_exit_code().unwrap_or_exit();
} }
} }
@ -411,7 +409,6 @@ fn show(rt: &Runtime) {
vec![date, comm] vec![date, comm]
} }
let mut out = ::std::io::stdout();
let header = ["#", "Date", "Comment"] let header = ["#", "Date", "Comment"]
.iter() .iter()
.map(|s| Cell::new(s)) .map(|s| Cell::new(s))
@ -433,7 +430,7 @@ fn show(rt: &Runtime) {
let recur = habit.habit_recur_spec().map_err_trace_exit_unwrap(1); let recur = habit.habit_recur_spec().map_err_trace_exit_unwrap(1);
let comm = habit.habit_comment().map_err_trace_exit_unwrap(1); let comm = habit.habit_comment().map_err_trace_exit_unwrap(1);
let _ = writeln!(out, let _ = writeln!(rt.stdout(),
"{i} - {name}\nBase : {b},\nRecurrence: {r}\nComment : {c}\n", "{i} - {name}\nBase : {b},\nRecurrence: {r}\nComment : {c}\n",
i = i, i = i,
name = name, name = name,
@ -461,8 +458,7 @@ fn show(rt: &Runtime) {
}); });
if !empty { if !empty {
let mut out = ::std::io::stdout(); let _ = table.print(&mut rt.stdout()).to_exit_code().unwrap_or_exit();
let _ = table.print(&mut out).to_exit_code().unwrap_or_exit();
} }
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();

View file

@ -137,7 +137,7 @@ fn show(rt: &Runtime) {
} }
let id = e.diary_id().map_err_trace_exit_unwrap(1); let id = e.diary_id().map_err_trace_exit_unwrap(1);
writeln!(::std::io::stdout(), writeln!(rt.stdout(),
"{dname: >10} - {y: >4}-{m:0>2}-{d:0>2}T{H:0>2}:{M:0>2} - {text}", "{dname: >10} - {y: >4}-{m:0>2}-{d:0>2}T{H:0>2}:{M:0>2} - {text}",
dname = id.diary_name(), dname = id.diary_name(),
y = id.year(), y = id.year(),

View file

@ -73,7 +73,7 @@ fn list(rt: &Runtime) {
use libimagmail::error::ResultExt; use libimagmail::error::ResultExt;
// TODO: Implement lister type in libimagmail for this // TODO: Implement lister type in libimagmail for this
fn list_mail(m: Mail) { fn list_mail(rt: &Runtime, m: Mail) {
let id = match m.get_message_id() { let id = match m.get_message_id() {
Ok(Some(f)) => f, Ok(Some(f)) => f,
Ok(None) => "<no id>".to_owned(), Ok(None) => "<no id>".to_owned(),
@ -110,7 +110,7 @@ fn list(rt: &Runtime) {
}, },
}; };
writeln!(::std::io::stdout(), writeln!(rt.stdout(),
"Mail: {id}\n\tFrom: {from}\n\tTo: {to}\n\t{subj}\n", "Mail: {id}\n\tFrom: {from}\n\tTo: {to}\n\t{subj}\n",
from = from, from = from,
id = id, id = id,
@ -130,7 +130,7 @@ fn list(rt: &Runtime) {
.map(|fle| Mail::from_fle(fle).map_err_trace().ok()) .map(|fle| Mail::from_fle(fle).map_err_trace().ok())
}) })
.filter_map(|e| e) .filter_map(|e| e)
.for_each(list_mail); .for_each(|m| list_mail(&rt, m));
} }
fn mail_store(rt: &Runtime) { fn mail_store(rt: &Runtime) {

View file

@ -119,8 +119,6 @@ fn edit(rt: &Runtime) {
fn list(rt: &Runtime) { fn list(rt: &Runtime) {
use std::cmp::Ordering; use std::cmp::Ordering;
let mut out = ::std::io::stdout();
let _ = rt let _ = rt
.store() .store()
.all_notes() .all_notes()
@ -139,7 +137,7 @@ fn list(rt: &Runtime) {
.iter() .iter()
.for_each(|note| { .for_each(|note| {
let name = note.get_name().map_err_trace_exit_unwrap(1); let name = note.get_name().map_err_trace_exit_unwrap(1);
writeln!(out, "{}", name) writeln!(rt.stdout(), "{}", name)
.to_exit_code() .to_exit_code()
.unwrap_or_exit() .unwrap_or_exit()
}); });

View file

@ -86,7 +86,6 @@ pub fn day(rt: &Runtime) -> i32 {
tags_filter.and(start_time_filter).and(end_time_filter) tags_filter.and(start_time_filter).and(end_time_filter)
}; };
let mut out = ::std::io::stdout();
rt.store() rt.store()
.get_timetrackings() .get_timetrackings()
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
@ -111,9 +110,9 @@ pub fn day(rt: &Runtime) -> i32 {
.trace_unwrap_exit(1) .trace_unwrap_exit(1)
.map(|(tag, start, end)| { .map(|(tag, start, end)| {
match (start, end) { match (start, end) {
(None, _) => writeln!(out, "{} has no start time.", tag), (None, _) => writeln!(rt.stdout(), "{} has no start time.", tag),
(Some(s), None) => writeln!(out, "{} | {} - ...", tag, s), (Some(s), None) => writeln!(rt.stdout(), "{} | {} - ...", tag, s),
(Some(s), Some(e)) => writeln!(out, "{} | {} - {}", tag, s, e), (Some(s), Some(e)) => writeln!(rt.stdout(), "{} | {} - {}", tag, s, e),
} }
.to_exit_code() .to_exit_code()
}) })

View file

@ -117,8 +117,6 @@ pub fn list_impl(rt: &Runtime,
let mut table = Table::new(); let mut table = Table::new();
table.set_titles(Row::new(["Tag", "Start", "End"].into_iter().map(|s| Cell::new(s)).collect())); table.set_titles(Row::new(["Tag", "Start", "End"].into_iter().map(|s| Cell::new(s)).collect()));
let mut stdout = ::std::io::stdout();
rt.store() rt.store()
.get_timetrackings() .get_timetrackings()
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
@ -167,7 +165,7 @@ pub fn list_impl(rt: &Runtime,
}) })
}) })
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.print(&mut stdout) .print(&mut rt.stdout())
.map_err(|_| TimeTrackError::from(String::from("Failed printing table"))) .map_err(|_| TimeTrackError::from(String::from("Failed printing table")))
.map(|_| 0) .map(|_| 0)
.map_err_trace() .map_err_trace()

View file

@ -101,8 +101,6 @@ pub fn month(rt: &Runtime) -> i32 {
tags_filter.and(start_time_filter).and(end_time_filter) tags_filter.and(start_time_filter).and(end_time_filter)
}; };
let mut out = ::std::io::stdout();
rt.store() rt.store()
.get_timetrackings() .get_timetrackings()
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
@ -127,9 +125,9 @@ pub fn month(rt: &Runtime) -> i32 {
.trace_unwrap_exit(1) .trace_unwrap_exit(1)
.map(|(tag, start, end)| { .map(|(tag, start, end)| {
match (start, end) { match (start, end) {
(None, _) => writeln!(out, "{} has no start time.", tag), (None, _) => writeln!(rt.stdout(), "{} has no start time.", tag),
(Some(s), None) => writeln!(out, "{} | {} - ...", tag, s), (Some(s), None) => writeln!(rt.stdout(), "{} | {} - ...", tag, s),
(Some(s), Some(e)) => writeln!(out, "{} | {} - {}", tag, s, e), (Some(s), Some(e)) => writeln!(rt.stdout(), "{} | {} - {}", tag, s, e),
} }
.to_exit_code() .to_exit_code()
}) })

View file

@ -99,7 +99,6 @@ pub fn week(rt: &Runtime) -> i32 {
tags_filter.and(start_time_filter).and(end_time_filter) tags_filter.and(start_time_filter).and(end_time_filter)
}; };
let mut out = ::std::io::stdout();
rt.store() rt.store()
.get_timetrackings() .get_timetrackings()
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
@ -124,9 +123,9 @@ pub fn week(rt: &Runtime) -> i32 {
.trace_unwrap_exit(1) .trace_unwrap_exit(1)
.map(|(tag, start, end)| { .map(|(tag, start, end)| {
match (start, end) { match (start, end) {
(None, _) => writeln!(out, "{} has no start time.", tag), (None, _) => writeln!(rt.stdout(), "{} has no start time.", tag),
(Some(s), None) => writeln!(out, "{} | {} - ...", tag, s), (Some(s), None) => writeln!(rt.stdout(), "{} | {} - ...", tag, s),
(Some(s), Some(e)) => writeln!(out, "{} | {} - {}", tag, s, e), (Some(s), Some(e)) => writeln!(rt.stdout(), "{} | {} - {}", tag, s, e),
} }
.to_exit_code() .to_exit_code()
}) })

View file

@ -98,7 +98,7 @@ pub fn year(rt: &Runtime) -> i32 {
tags_filter.and(start_time_filter).and(end_time_filter) tags_filter.and(start_time_filter).and(end_time_filter)
}; };
let mut out = ::std::io::stdout(); let mut out = rt.stdout();
rt.store() rt.store()
.get_timetrackings() .get_timetrackings()
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)

View file

@ -71,7 +71,7 @@ fn tw_hook(rt: &Runtime) {
.import_task_from_reader(stdin) .import_task_from_reader(stdin)
.map_err_trace_exit_unwrap(1); .map_err_trace_exit_unwrap(1);
let _ = writeln!(::std::io::stdout(), "{}\nTask {} stored in imag", line, uuid) let _ = writeln!(rt.stdout(), "{}\nTask {} stored in imag", line, uuid)
.to_exit_code() .to_exit_code()
.unwrap_or_exit(); .unwrap_or_exit();
@ -148,7 +148,7 @@ fn list(rt: &Runtime) {
}; };
// and then print that // and then print that
let _ = writeln!(::std::io::stdout(), "{}", outstring).to_exit_code().unwrap_or_exit(); let _ = writeln!(rt.stdout(), "{}", outstring).to_exit_code().unwrap_or_exit();
}); });
res.map_err_trace().ok(); res.map_err_trace().ok();