mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 17:57:19 +02:00
Run cargo clippy
This commit is contained in:
parent
fa86430395
commit
e5c4c5c702
3 changed files with 79 additions and 87 deletions
48
src/app.rs
48
src/app.rs
|
@ -77,7 +77,7 @@ pub fn get_date_state(reference: &Date) -> DateState {
|
|||
return DateState::LaterToday;
|
||||
}
|
||||
}
|
||||
return DateState::AfterToday;
|
||||
DateState::AfterToday
|
||||
}
|
||||
|
||||
pub fn vague_format_date_time(from_dt: NaiveDateTime, to_dt: NaiveDateTime) -> String {
|
||||
|
@ -193,7 +193,7 @@ impl TaskReportTable {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn generate_table(&mut self, tasks: &Vec<Task>) {
|
||||
pub fn generate_table(&mut self, tasks: &[Task]) {
|
||||
self.tasks = vec![];
|
||||
|
||||
// get all tasks as their string representation
|
||||
|
@ -298,15 +298,15 @@ impl TaskReportTable {
|
|||
None => "".to_string(),
|
||||
},
|
||||
"project" => match task.project() {
|
||||
Some(p) => format!("{}", p).to_string(),
|
||||
Some(p) => p.to_string(),
|
||||
None => "".to_string(),
|
||||
},
|
||||
"depends.count" => match task.depends() {
|
||||
Some(v) => {
|
||||
if v.len() == 0 {
|
||||
if v.is_empty() {
|
||||
"".to_string()
|
||||
} else {
|
||||
format!("{}", v.len()).to_string()
|
||||
format!("{}", v.len())
|
||||
}
|
||||
}
|
||||
None => "".to_string(),
|
||||
|
@ -314,28 +314,26 @@ impl TaskReportTable {
|
|||
"tags.count" => match task.tags() {
|
||||
Some(v) => {
|
||||
let t = v
|
||||
.into_iter()
|
||||
.iter()
|
||||
.filter(|t| !tags.contains(&t.as_str()))
|
||||
.cloned()
|
||||
.collect::<Vec<String>>()
|
||||
.len();
|
||||
.count();
|
||||
if t == 0 {
|
||||
"".to_string()
|
||||
} else {
|
||||
format!("{}", t).to_string()
|
||||
t.to_string()
|
||||
}
|
||||
}
|
||||
None => "".to_string(),
|
||||
},
|
||||
"tags" => match task.tags() {
|
||||
Some(v) => {
|
||||
let t = v
|
||||
.iter()
|
||||
.filter(|t| !tags.contains(&t.as_str()))
|
||||
.cloned()
|
||||
.collect::<Vec<String>>()
|
||||
.join(",");
|
||||
format!("{}", t).to_string()
|
||||
v
|
||||
.iter()
|
||||
.filter(|t| !tags.contains(&t.as_str()))
|
||||
.cloned()
|
||||
.collect::<Vec<String>>()
|
||||
.join(",")
|
||||
}
|
||||
None => "".to_string(),
|
||||
},
|
||||
|
@ -343,8 +341,8 @@ impl TaskReportTable {
|
|||
"description" => task.description().to_string(),
|
||||
"urgency" => match &task.uda()["urgency"] {
|
||||
UDAValue::Str(_) => "0.00".to_string(),
|
||||
UDAValue::U64(u) => format!("{:.2}", *u as f64).to_string(),
|
||||
UDAValue::F64(f) => format!("{:.2}", *f).to_string(),
|
||||
UDAValue::U64(u) => format!("{:.2}", *u as f64),
|
||||
UDAValue::F64(f) => format!("{:.2}", *f),
|
||||
},
|
||||
_ => "".to_string(),
|
||||
}
|
||||
|
@ -765,7 +763,7 @@ impl TTApp {
|
|||
.fg(self.config.color_due_today.fg)
|
||||
.bg(self.config.color_due_today.bg);
|
||||
}
|
||||
return style;
|
||||
style
|
||||
}
|
||||
|
||||
fn draw_task_report(&mut self, f: &mut Frame<impl Backend>, rect: Rect) {
|
||||
|
@ -825,7 +823,7 @@ impl TTApp {
|
|||
if i == selected {
|
||||
highlight_style = style.add_modifier(Modifier::BOLD);
|
||||
}
|
||||
rows.push(Row::StyledData(task.into_iter(), style));
|
||||
rows.push(Row::StyledData(task.iter(), style));
|
||||
}
|
||||
|
||||
let constraints: Vec<Constraint> = widths
|
||||
|
@ -896,7 +894,7 @@ impl TTApp {
|
|||
task.arg("rc.json.array=on");
|
||||
task.arg("export");
|
||||
|
||||
let filter = if self.context_filter != "".to_string() {
|
||||
let filter = if self.context_filter != *"" {
|
||||
let t = format!("{} {}", self.filter.as_str(), self.context_filter);
|
||||
t
|
||||
} else {
|
||||
|
@ -1484,11 +1482,7 @@ impl TTApp {
|
|||
}
|
||||
_ => handle_movement(&mut self.command, input),
|
||||
},
|
||||
AppMode::TaskError => match input {
|
||||
_ => {
|
||||
self.mode = AppMode::TaskReport;
|
||||
}
|
||||
},
|
||||
AppMode::TaskError => self.mode = AppMode::TaskReport,
|
||||
AppMode::Calendar => match input {
|
||||
Key::Char('[') => {
|
||||
self.mode = AppMode::TaskReport;
|
||||
|
@ -1550,7 +1544,7 @@ pub fn handle_movement(linebuffer: &mut LineBuffer, input: Key) {
|
|||
|
||||
pub fn add_tag(task: &mut Task, tag: String) {
|
||||
match task.tags_mut() {
|
||||
Some(t) => t.push(tag.to_string()),
|
||||
Some(t) => t.push(tag),
|
||||
None => task.set_tags(Some(vec![tag])),
|
||||
}
|
||||
}
|
||||
|
|
116
src/config.rs
116
src/config.rs
|
@ -81,27 +81,25 @@ pub fn get_color(s: &str) -> Color {
|
|||
let green = (s.as_bytes()[4] as char).to_digit(10).unwrap() as u8;
|
||||
let blue = (s.as_bytes()[5] as char).to_digit(10).unwrap() as u8;
|
||||
Color::Indexed(16 + red * 36 + green * 6 + blue)
|
||||
} else if s == "white" {
|
||||
Color::White
|
||||
} else if s == "black" {
|
||||
Color::Black
|
||||
} else {
|
||||
if s == "white" {
|
||||
Color::White
|
||||
} else if s == "black" {
|
||||
Color::Black
|
||||
} else {
|
||||
Color::Indexed(15)
|
||||
}
|
||||
Color::Indexed(15)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_tcolor(line: &str) -> TColor {
|
||||
if line.contains(" on ") {
|
||||
let foreground = line.split(" ").collect::<Vec<&str>>()[0];
|
||||
let background = line.split(" ").collect::<Vec<&str>>()[2];
|
||||
let foreground = line.split(' ').collect::<Vec<&str>>()[0];
|
||||
let background = line.split(' ').collect::<Vec<&str>>()[2];
|
||||
TColor {
|
||||
fg: get_color(foreground),
|
||||
bg: get_color(background),
|
||||
}
|
||||
} else if line.contains("on ") {
|
||||
let background = line.split(" ").collect::<Vec<&str>>()[1];
|
||||
let background = line.split(' ').collect::<Vec<&str>>()[1];
|
||||
TColor {
|
||||
fg: Color::Indexed(0),
|
||||
bg: get_color(background),
|
||||
|
@ -186,7 +184,7 @@ impl TConfig {
|
|||
if line.starts_with(attribute) {
|
||||
color_collection.insert(
|
||||
attribute.to_string(),
|
||||
get_tcolor(line.trim_start_matches(attribute).trim_start_matches(" ")),
|
||||
get_tcolor(line.trim_start_matches(attribute).trim_start_matches(' ')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -198,7 +196,7 @@ impl TConfig {
|
|||
if line.starts_with(attribute) {
|
||||
bool_collection.insert(
|
||||
attribute.to_string(),
|
||||
line.trim_start_matches(attribute).trim_start_matches(" ") == "yes",
|
||||
line.trim_start_matches(attribute).trim_start_matches(' ') == "yes",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -208,119 +206,119 @@ impl TConfig {
|
|||
enabled: true,
|
||||
obfuscate: bool_collection.get("obfuscate").cloned().unwrap_or(false),
|
||||
print_empty_columns: bool_collection.get("print_empty_columns").cloned().unwrap_or(false),
|
||||
color_active: color_collection.get("active").cloned().unwrap_or(TColor::default()),
|
||||
color_alternate: color_collection.get("alternate").cloned().unwrap_or(TColor::default()),
|
||||
color_blocked: color_collection.get("blocked").cloned().unwrap_or(TColor::default()),
|
||||
color_blocking: color_collection.get("blocking").cloned().unwrap_or(TColor::default()),
|
||||
color_active: color_collection.get("active").cloned().unwrap_or_else(TColor::default),
|
||||
color_alternate: color_collection.get("alternate").cloned().unwrap_or_else(TColor::default),
|
||||
color_blocked: color_collection.get("blocked").cloned().unwrap_or_else(TColor::default),
|
||||
color_blocking: color_collection.get("blocking").cloned().unwrap_or_else(TColor::default),
|
||||
color_burndown_done: color_collection
|
||||
.get("burndown.done")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_burndown_pending: color_collection
|
||||
.get("burndown.pending")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_burndown_started: color_collection
|
||||
.get("burndown.started")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_calendar_due: color_collection
|
||||
.get("calendar.due")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_calendar_due_today: color_collection
|
||||
.get("calendar.due.today")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_calendar_holiday: color_collection
|
||||
.get("calendar.holiday")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_calendar_overdue: color_collection
|
||||
.get("calendar.overdue")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_calendar_today: color_collection
|
||||
.get("calendar.today")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_calendar_weekend: color_collection
|
||||
.get("calendar.weekend")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_calendar_weeknumber: color_collection
|
||||
.get("calendar.weeknumber")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
color_completed: color_collection.get("completed").cloned().unwrap_or(TColor::default()),
|
||||
color_debug: color_collection.get("debug").cloned().unwrap_or(TColor::default()),
|
||||
color_deleted: color_collection.get("deleted").cloned().unwrap_or(TColor::default()),
|
||||
color_due: color_collection.get("due").cloned().unwrap_or(TColor::default()),
|
||||
color_due_today: color_collection.get("due.today").cloned().unwrap_or(TColor::default()),
|
||||
color_error: color_collection.get("error").cloned().unwrap_or(TColor::default()),
|
||||
color_footnote: color_collection.get("footnote").cloned().unwrap_or(TColor::default()),
|
||||
color_header: color_collection.get("header").cloned().unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_completed: color_collection.get("completed").cloned().unwrap_or_else(TColor::default),
|
||||
color_debug: color_collection.get("debug").cloned().unwrap_or_else(TColor::default),
|
||||
color_deleted: color_collection.get("deleted").cloned().unwrap_or_else(TColor::default),
|
||||
color_due: color_collection.get("due").cloned().unwrap_or_else(TColor::default),
|
||||
color_due_today: color_collection.get("due.today").cloned().unwrap_or_else(TColor::default),
|
||||
color_error: color_collection.get("error").cloned().unwrap_or_else(TColor::default),
|
||||
color_footnote: color_collection.get("footnote").cloned().unwrap_or_else(TColor::default),
|
||||
color_header: color_collection.get("header").cloned().unwrap_or_else(TColor::default),
|
||||
color_history_add: color_collection
|
||||
.get("history.add")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_history_delete: color_collection
|
||||
.get("history.delete")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_history_done: color_collection
|
||||
.get("history.done")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
color_label: color_collection.get("label").cloned().unwrap_or(TColor::default()),
|
||||
color_label_sort: color_collection.get("label.sort").cloned().unwrap_or(TColor::default()),
|
||||
color_overdue: color_collection.get("overdue").cloned().unwrap_or(TColor::default()),
|
||||
color_project: color_collection.get("project").cloned().unwrap_or(TColor::default()),
|
||||
color_recurring: color_collection.get("recurring").cloned().unwrap_or(TColor::default()),
|
||||
color_scheduled: color_collection.get("scheduled").cloned().unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_label: color_collection.get("label").cloned().unwrap_or_else(TColor::default),
|
||||
color_label_sort: color_collection.get("label.sort").cloned().unwrap_or_else(TColor::default),
|
||||
color_overdue: color_collection.get("overdue").cloned().unwrap_or_else(TColor::default),
|
||||
color_project: color_collection.get("project").cloned().unwrap_or_else(TColor::default),
|
||||
color_recurring: color_collection.get("recurring").cloned().unwrap_or_else(TColor::default),
|
||||
color_scheduled: color_collection.get("scheduled").cloned().unwrap_or_else(TColor::default),
|
||||
color_summary_background: color_collection
|
||||
.get("summary.background")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_summary_bar: color_collection
|
||||
.get("summary_bar")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
color_sync_added: color_collection.get("sync.added").cloned().unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_sync_added: color_collection.get("sync.added").cloned().unwrap_or_else(TColor::default),
|
||||
color_sync_changed: color_collection
|
||||
.get("sync.changed")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_sync_rejected: color_collection
|
||||
.get("sync.rejected")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
color_tag_next: color_collection.get("tag.next").cloned().unwrap_or(TColor::default()),
|
||||
color_tag: color_collection.get("tag").cloned().unwrap_or(TColor::default()),
|
||||
color_tagged: color_collection.get("tagged").cloned().unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_tag_next: color_collection.get("tag.next").cloned().unwrap_or_else(TColor::default),
|
||||
color_tag: color_collection.get("tag").cloned().unwrap_or_else(TColor::default),
|
||||
color_tagged: color_collection.get("tagged").cloned().unwrap_or_else(TColor::default),
|
||||
color_uda_priority: color_collection
|
||||
.get("uda.priority")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_uda_priority_h: color_collection
|
||||
.get("uda.priority.h")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_uda_priority_l: color_collection
|
||||
.get("uda.priority.l")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_uda_priority_m: color_collection
|
||||
.get("uda.priority.m")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
color_undo_after: color_collection.get("undo.after").cloned().unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_undo_after: color_collection.get("undo.after").cloned().unwrap_or_else(TColor::default),
|
||||
color_undo_before: color_collection
|
||||
.get("undo.before")
|
||||
.cloned()
|
||||
.unwrap_or(TColor::default()),
|
||||
color_until: color_collection.get("until").cloned().unwrap_or(TColor::default()),
|
||||
color_warning: color_collection.get("warning").cloned().unwrap_or(TColor::default()),
|
||||
.unwrap_or_else(TColor::default),
|
||||
color_until: color_collection.get("until").cloned().unwrap_or_else(TColor::default),
|
||||
color_warning: color_collection.get("warning").cloned().unwrap_or_else(TColor::default),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ impl Events {
|
|||
let pause_stdin = pause_stdin.clone();
|
||||
thread::spawn(move || {
|
||||
loop {
|
||||
if *pause_stdin.lock().unwrap() == true {
|
||||
if *pause_stdin.lock().unwrap() {
|
||||
thread::sleep(Duration::from_millis(250));
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue