mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-23 20:16:41 +02:00
WIP
This commit is contained in:
parent
9b7b83607a
commit
e136c23959
3 changed files with 26 additions and 4 deletions
2
.envrc
2
.envrc
|
@ -3,5 +3,3 @@ export TASKDATA=`pwd`/tests/data/.task
|
|||
export TASKWARRIOR_TUI_CONFIG=`pwd`/tests/data/.config
|
||||
export TASKWARRIOR_TUI_DATA=`pwd`/tests/data/.data
|
||||
export TASKWARRIOR_TUI_LOG_LEVEL=debug
|
||||
export RUST_LOG=debug
|
||||
export RUST_BACKTRACE=full
|
||||
|
|
2
build.rs
2
build.rs
|
@ -1,4 +1,6 @@
|
|||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_variables)]
|
||||
use std::process::{Command, Output};
|
||||
|
||||
use clap_complete::{
|
||||
|
|
|
@ -31,6 +31,11 @@ impl TaskReport {
|
|||
Self::default()
|
||||
}
|
||||
|
||||
pub fn report(mut self, report: String) -> Self {
|
||||
self.report = report;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn refresh(&mut self) -> Result<()> {
|
||||
self.last_export = Some(std::time::SystemTime::now());
|
||||
Ok(())
|
||||
|
@ -78,10 +83,13 @@ impl TaskReport {
|
|||
let error = String::from_utf8_lossy(&output.stderr);
|
||||
|
||||
if output.status.success() {
|
||||
if let Ok(imported) = import(data.as_bytes()) {
|
||||
self.tasks = imported;
|
||||
let imported = import(data.as_bytes());
|
||||
if imported.is_ok() {
|
||||
self.tasks = imported?;
|
||||
log::info!("Imported {} tasks", self.tasks.len());
|
||||
self.send_command(Command::ShowTaskReport)?;
|
||||
} else {
|
||||
imported?;
|
||||
}
|
||||
} else {
|
||||
self.send_command(Command::Error(format!("Unable to parse output of `{:?}`:\n`{:?}`", task, data)))?;
|
||||
|
@ -113,3 +121,17 @@ impl Component for TaskReport {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_export() -> Result<()> {
|
||||
let mut tr = TaskReport::new().report("next".into());
|
||||
tr.task_export()?;
|
||||
assert_eq!(tr.tasks.len(), 33);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue