Replace 'failure' crate with anyhow+thiserror

Closes #148
This commit is contained in:
dbr
2021-03-25 16:33:35 +11:00
parent 3cccdc7e32
commit 4d9755c43b
41 changed files with 255 additions and 316 deletions

View File

@@ -1,5 +1,4 @@
use crate::argparse::{DescriptionMod, Modification};
use failure::Fallible;
use taskchampion::{Replica, Status};
use termcolor::WriteColor;
@@ -7,7 +6,7 @@ pub(crate) fn execute<W: WriteColor>(
w: &mut W,
replica: &mut Replica,
modification: Modification,
) -> Fallible<()> {
) -> anyhow::Result<()> {
let description = match modification.description {
DescriptionMod::Set(ref s) => s.clone(),
_ => "(no description)".to_owned(),

View File

@@ -1,8 +1,7 @@
use failure::Fallible;
use taskchampion::Replica;
use termcolor::WriteColor;
pub(crate) fn execute<W: WriteColor>(w: &mut W, replica: &mut Replica) -> Fallible<()> {
pub(crate) fn execute<W: WriteColor>(w: &mut W, replica: &mut Replica) -> anyhow::Result<()> {
log::debug!("rebuilding working set");
replica.rebuild_working_set(true)?;
writeln!(w, "garbage collected.")?;

View File

@@ -1,12 +1,11 @@
use crate::usage::Usage;
use failure::Fallible;
use termcolor::WriteColor;
pub(crate) fn execute<W: WriteColor>(
w: &mut W,
command_name: String,
summary: bool,
) -> Fallible<()> {
) -> anyhow::Result<()> {
let usage = Usage::new();
usage.write_help(w, command_name.as_ref(), summary)?;
Ok(())

View File

@@ -1,7 +1,6 @@
use crate::argparse::Filter;
use crate::invocation::filtered_tasks;
use crate::table;
use failure::Fallible;
use prettytable::{cell, row, Table};
use taskchampion::Replica;
use termcolor::WriteColor;
@@ -11,7 +10,7 @@ pub(crate) fn execute<W: WriteColor>(
replica: &mut Replica,
filter: Filter,
debug: bool,
) -> Fallible<()> {
) -> anyhow::Result<()> {
let working_set = replica.working_set()?;
for task in filtered_tasks(replica, &filter)? {

View File

@@ -1,6 +1,5 @@
use crate::argparse::{Filter, Modification};
use crate::invocation::{apply_modification, filtered_tasks};
use failure::Fallible;
use taskchampion::Replica;
use termcolor::WriteColor;
@@ -9,7 +8,7 @@ pub(crate) fn execute<W: WriteColor>(
replica: &mut Replica,
filter: Filter,
modification: Modification,
) -> Fallible<()> {
) -> anyhow::Result<()> {
for task in filtered_tasks(replica, &filter)? {
let mut task = task.into_mut(replica);

View File

@@ -1,7 +1,6 @@
use crate::argparse::Filter;
use crate::invocation::display_report;
use config::Config;
use failure::Fallible;
use taskchampion::Replica;
use termcolor::WriteColor;
@@ -11,7 +10,7 @@ pub(crate) fn execute<W: WriteColor>(
settings: &Config,
report_name: String,
filter: Filter,
) -> Fallible<()> {
) -> anyhow::Result<()> {
display_report(w, replica, settings, report_name, filter)
}

View File

@@ -1,4 +1,3 @@
use failure::Fallible;
use taskchampion::{server::Server, Replica};
use termcolor::WriteColor;
@@ -6,8 +5,8 @@ pub(crate) fn execute<W: WriteColor>(
w: &mut W,
replica: &mut Replica,
server: &mut Box<dyn Server>,
) -> Fallible<()> {
replica.sync(server)?;
) -> anyhow::Result<()> {
replica.sync(server).unwrap();
writeln!(w, "sync complete.")?;
Ok(())
}

View File

@@ -1,7 +1,6 @@
use failure::Fallible;
use termcolor::{ColorSpec, WriteColor};
pub(crate) fn execute<W: WriteColor>(w: &mut W) -> Fallible<()> {
pub(crate) fn execute<W: WriteColor>(w: &mut W) -> anyhow::Result<()> {
write!(w, "TaskChampion ")?;
w.set_color(ColorSpec::new().set_bold(true))?;
writeln!(w, "{}", env!("CARGO_PKG_VERSION"))?;