mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 08:47:18 +02:00
Merge pull request #173 from kdheepak/fix-ci
This commit is contained in:
commit
7826c300df
5 changed files with 47 additions and 172 deletions
2
.github/workflows/cd.yml
vendored
2
.github/workflows/cd.yml
vendored
|
@ -277,7 +277,7 @@ jobs:
|
|||
env:
|
||||
TASKRC: taskwarrior-testdata/.taskrc
|
||||
TASKDATA: taskwarrior-testdata/.task
|
||||
RUST_BACKTRACE: 1
|
||||
RUST_BACKTRACE: full
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install toolchain
|
||||
|
|
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -23,7 +23,7 @@ jobs:
|
|||
env:
|
||||
TASKRC: taskwarrior-testdata/.taskrc
|
||||
TASKDATA: taskwarrior-testdata/.task
|
||||
RUST_BACKTRACE: 1
|
||||
RUST_BACKTRACE: full
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
|
@ -36,6 +36,8 @@ jobs:
|
|||
with:
|
||||
repository: kdheepak/taskwarrior-testdata
|
||||
path: taskwarrior-testdata
|
||||
- run: |
|
||||
ulimit -a
|
||||
- run: |
|
||||
# prepare taskwarrior, initial setup
|
||||
task rc.confirmation=off || echo 0
|
||||
|
|
21
src/app.rs
21
src/app.rs
|
@ -219,7 +219,8 @@ impl TaskwarriorTuiApp {
|
|||
}
|
||||
|
||||
let data = String::from_utf8_lossy(&output.stdout);
|
||||
let (c, kc) = task::block_on(async { try_join!(Config::new(&data), KeyConfig::new(&data)) })?;
|
||||
let c = Config::new(&data)?;
|
||||
let kc = KeyConfig::new(&data)?;
|
||||
|
||||
let (w, h) = crossterm::terminal::size()?;
|
||||
|
||||
|
@ -2354,18 +2355,10 @@ mod tests {
|
|||
std::fs::remove_dir_all(cd).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_taskwarrior_timing() {
|
||||
let app = TaskwarriorTuiApp::new();
|
||||
if app.is_err() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_taskwarrior_tui() {
|
||||
let app = TaskwarriorTuiApp::new();
|
||||
if app.is_err() {
|
||||
if let Err(_) = app {
|
||||
return;
|
||||
}
|
||||
let app = app.unwrap();
|
||||
|
@ -3143,23 +3136,23 @@ mod tests {
|
|||
}
|
||||
|
||||
for i in 3..=22 {
|
||||
expected.get_mut(i, 4).set_style(Style::default().bg(Color::Black));
|
||||
expected.get_mut(i, 4).set_style(Style::default().bg(Color::Reset));
|
||||
}
|
||||
|
||||
for i in 25..=44 {
|
||||
expected.get_mut(i, 4).set_style(Style::default().bg(Color::Black));
|
||||
expected.get_mut(i, 4).set_style(Style::default().bg(Color::Reset));
|
||||
}
|
||||
|
||||
for i in 3..=22 {
|
||||
expected
|
||||
.get_mut(i, 5)
|
||||
.set_style(Style::default().bg(Color::Black).add_modifier(Modifier::UNDERLINED));
|
||||
.set_style(Style::default().bg(Color::Reset).add_modifier(Modifier::UNDERLINED));
|
||||
}
|
||||
|
||||
for i in 25..=44 {
|
||||
expected
|
||||
.get_mut(i, 5)
|
||||
.set_style(Style::default().bg(Color::Black).add_modifier(Modifier::UNDERLINED));
|
||||
.set_style(Style::default().bg(Color::Reset).add_modifier(Modifier::UNDERLINED));
|
||||
}
|
||||
|
||||
test_case(&expected);
|
||||
|
|
127
src/config.rs
127
src/config.rs
|
@ -1,7 +1,5 @@
|
|||
#![allow(clippy::eval_order_dependence)]
|
||||
use anyhow::{Context, Result};
|
||||
use async_std::process::Command;
|
||||
use async_std::task;
|
||||
use futures::join;
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use std::str;
|
||||
|
@ -64,7 +62,7 @@ pub struct Config {
|
|||
}
|
||||
|
||||
impl Config {
|
||||
pub async fn new(data: &str) -> Result<Self> {
|
||||
pub fn new(data: &str) -> Result<Self> {
|
||||
let bool_collection = Self::get_bool_collection();
|
||||
|
||||
let enabled = true;
|
||||
|
@ -93,53 +91,6 @@ impl Config {
|
|||
let uda_style_context_active = Self::get_uda_style("context.active", data);
|
||||
let uda_shortcuts = Self::get_uda_shortcuts(data);
|
||||
|
||||
let (
|
||||
color,
|
||||
filter,
|
||||
data_location,
|
||||
due,
|
||||
rule_precedence_color,
|
||||
uda_tick_rate,
|
||||
uda_prefill_task_metadata,
|
||||
uda_task_detail_prefetch,
|
||||
uda_task_report_show_info,
|
||||
uda_task_report_looping,
|
||||
uda_selection_indicator,
|
||||
uda_mark_indicator,
|
||||
uda_unmark_indicator,
|
||||
uda_selection_bold,
|
||||
uda_selection_italic,
|
||||
uda_selection_dim,
|
||||
uda_selection_blink,
|
||||
uda_calendar_months_per_row,
|
||||
uda_style_calendar_title,
|
||||
uda_style_context_active,
|
||||
uda_shortcuts,
|
||||
) = join!(
|
||||
color,
|
||||
filter,
|
||||
data_location,
|
||||
due,
|
||||
rule_precedence_color,
|
||||
uda_tick_rate,
|
||||
uda_prefill_task_metadata,
|
||||
uda_task_detail_prefetch,
|
||||
uda_task_report_show_info,
|
||||
uda_task_report_looping,
|
||||
uda_selection_indicator,
|
||||
uda_mark_indicator,
|
||||
uda_unmark_indicator,
|
||||
uda_selection_bold,
|
||||
uda_selection_italic,
|
||||
uda_selection_dim,
|
||||
uda_selection_blink,
|
||||
uda_calendar_months_per_row,
|
||||
uda_style_calendar_title,
|
||||
uda_style_context_active,
|
||||
uda_shortcuts,
|
||||
);
|
||||
|
||||
let color = color?;
|
||||
let uda_style_calendar_title = uda_style_calendar_title.unwrap_or_default();
|
||||
let uda_style_context_active = uda_style_context_active.unwrap_or_default();
|
||||
|
||||
|
@ -175,23 +126,23 @@ impl Config {
|
|||
HashMap::new()
|
||||
}
|
||||
|
||||
async fn get_uda_shortcuts(data: &str) -> Vec<String> {
|
||||
fn get_uda_shortcuts(data: &str) -> Vec<String> {
|
||||
let mut v = vec![];
|
||||
for s in 0..=9 {
|
||||
let c = format!("uda.taskwarrior-tui.shortcuts.{}", s);
|
||||
let s = Self::get_config(&c, data).await.unwrap_or_default();
|
||||
let s = Self::get_config(&c, data).unwrap_or_default();
|
||||
v.push(s);
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
async fn get_uda_style(config: &str, data: &str) -> Option<Style> {
|
||||
fn get_uda_style(config: &str, data: &str) -> Option<Style> {
|
||||
let c = format!("uda.taskwarrior-tui.style.{}", config);
|
||||
let s = Self::get_config(&c, data).await?;
|
||||
let s = Self::get_config(&c, data)?;
|
||||
Some(Self::get_tcolor(&s))
|
||||
}
|
||||
|
||||
async fn get_color_collection(data: &str) -> Result<HashMap<String, Style>> {
|
||||
fn get_color_collection(data: &str) -> HashMap<String, Style> {
|
||||
let mut color_collection = HashMap::new();
|
||||
for line in data.split('\n') {
|
||||
if line.starts_with("color.") {
|
||||
|
@ -200,14 +151,12 @@ impl Config {
|
|||
let line = i.collect::<Vec<_>>().join(" ");
|
||||
let line = line.trim_start_matches(' ');
|
||||
let tcolor = Self::get_tcolor(&line);
|
||||
match attribute {
|
||||
Some(attr) => color_collection.insert(attr.to_string(), tcolor),
|
||||
None => None,
|
||||
if let Some(attr) = attribute {
|
||||
color_collection.insert(attr.to_string(), tcolor);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Ok(color_collection)
|
||||
color_collection
|
||||
}
|
||||
|
||||
pub fn get_tcolor(line: &str) -> Style {
|
||||
|
@ -356,7 +305,7 @@ impl Config {
|
|||
}
|
||||
}
|
||||
|
||||
async fn get_config(config: &str, data: &str) -> Option<String> {
|
||||
fn get_config(config: &str, data: &str) -> Option<String> {
|
||||
for line in data.split('\n') {
|
||||
if line.starts_with(config) {
|
||||
return Some(line.trim_start_matches(config).trim_start().trim_end().to_string());
|
||||
|
@ -369,136 +318,122 @@ impl Config {
|
|||
None
|
||||
}
|
||||
|
||||
async fn get_due(data: &str) -> usize {
|
||||
fn get_due(data: &str) -> usize {
|
||||
Self::get_config("due", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.parse::<usize>()
|
||||
.unwrap_or(7)
|
||||
}
|
||||
|
||||
async fn get_rule_precedence_color(data: &str) -> Vec<String> {
|
||||
fn get_rule_precedence_color(data: &str) -> Vec<String> {
|
||||
let data = Self::get_config("rule.precedence.color", data)
|
||||
.await
|
||||
.context("Unable to parse `task show rule.precedence.color`.")
|
||||
.unwrap();
|
||||
data.split(',').map(|s| s.to_string()).collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
async fn get_filter(data: &str) -> String {
|
||||
fn get_filter(data: &str) -> String {
|
||||
let filter = Self::get_config("report.next.filter", data)
|
||||
.await
|
||||
.context("Unable to parse `task show report.next.filter`.")
|
||||
.unwrap();
|
||||
format!("{} ", filter)
|
||||
}
|
||||
|
||||
async fn get_data_location(data: &str) -> String {
|
||||
fn get_data_location(data: &str) -> String {
|
||||
Self::get_config("data.location", data)
|
||||
.await
|
||||
.context("Unable to parse `task show data.location`.")
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
async fn get_uda_prefill_task_metadata(data: &str) -> bool {
|
||||
fn get_uda_prefill_task_metadata(data: &str) -> bool {
|
||||
Self::get_config("uda.taskwarrior-tui.task-report.pre-fill-task-meta-data", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.get_bool()
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
async fn get_uda_tick_rate(data: &str) -> u64 {
|
||||
fn get_uda_tick_rate(data: &str) -> u64 {
|
||||
Self::get_config("uda.taskwarrior-tui.tick-rate", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.parse::<u64>()
|
||||
.unwrap_or(250)
|
||||
}
|
||||
|
||||
async fn get_uda_task_detail_prefetch(data: &str) -> usize {
|
||||
fn get_uda_task_detail_prefetch(data: &str) -> usize {
|
||||
Self::get_config("uda.taskwarrior-tui.task-report.task-detail-prefetch", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.parse::<usize>()
|
||||
.unwrap_or(10)
|
||||
}
|
||||
|
||||
async fn get_uda_task_report_show_info(data: &str) -> bool {
|
||||
fn get_uda_task_report_show_info(data: &str) -> bool {
|
||||
Self::get_config("uda.taskwarrior-tui.task-report.show-info", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.get_bool()
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
async fn get_uda_task_report_looping(data: &str) -> bool {
|
||||
fn get_uda_task_report_looping(data: &str) -> bool {
|
||||
Self::get_config("uda.taskwarrior-tui.task-report.looping", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.get_bool()
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
async fn get_uda_selection_indicator(data: &str) -> String {
|
||||
let indicator = Self::get_config("uda.taskwarrior-tui.selection.indicator", data).await;
|
||||
fn get_uda_selection_indicator(data: &str) -> String {
|
||||
let indicator = Self::get_config("uda.taskwarrior-tui.selection.indicator", data);
|
||||
match indicator {
|
||||
None => "• ".to_string(),
|
||||
Some(indicator) => format!("{} ", indicator),
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_uda_mark_indicator(data: &str) -> String {
|
||||
let indicator = Self::get_config("uda.taskwarrior-tui.mark.indicator", data).await;
|
||||
fn get_uda_mark_indicator(data: &str) -> String {
|
||||
let indicator = Self::get_config("uda.taskwarrior-tui.mark.indicator", data);
|
||||
match indicator {
|
||||
None => "✔ ".to_string(),
|
||||
Some(indicator) => format!("{} ", indicator),
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_uda_unmark_indicator(data: &str) -> String {
|
||||
let indicator = Self::get_config("uda.taskwarrior-tui.unmark.indicator", data).await;
|
||||
fn get_uda_unmark_indicator(data: &str) -> String {
|
||||
let indicator = Self::get_config("uda.taskwarrior-tui.unmark.indicator", data);
|
||||
match indicator {
|
||||
None => " ".to_string(),
|
||||
Some(indicator) => format!("{} ", indicator),
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_uda_selection_bold(data: &str) -> bool {
|
||||
fn get_uda_selection_bold(data: &str) -> bool {
|
||||
Self::get_config("uda.taskwarrior-tui.selection.bold", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.get_bool()
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
async fn get_uda_selection_italic(data: &str) -> bool {
|
||||
fn get_uda_selection_italic(data: &str) -> bool {
|
||||
Self::get_config("uda.taskwarrior-tui.selection.italic", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.get_bool()
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
async fn get_uda_selection_dim(data: &str) -> bool {
|
||||
fn get_uda_selection_dim(data: &str) -> bool {
|
||||
Self::get_config("uda.taskwarrior-tui.selection.dim", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.get_bool()
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
async fn get_uda_selection_blink(data: &str) -> bool {
|
||||
fn get_uda_selection_blink(data: &str) -> bool {
|
||||
Self::get_config("uda.taskwarrior-tui.selection.blink", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.get_bool()
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
async fn get_uda_months_per_row(data: &str) -> usize {
|
||||
fn get_uda_months_per_row(data: &str) -> usize {
|
||||
Self::get_config("uda.taskwarrior-tui.calendar.months-per-row", data)
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.parse::<usize>()
|
||||
.unwrap_or(4)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#![allow(clippy::eval_order_dependence)]
|
||||
use crate::util::Key;
|
||||
use anyhow::{anyhow, Result};
|
||||
use async_std::process::Command;
|
||||
use async_std::task;
|
||||
use futures::join;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
|
@ -92,13 +91,13 @@ impl Default for KeyConfig {
|
|||
}
|
||||
|
||||
impl KeyConfig {
|
||||
pub async fn new(data: &str) -> Result<Self> {
|
||||
pub fn new(data: &str) -> Result<Self> {
|
||||
let mut kc = Self::default();
|
||||
kc.update(data).await?;
|
||||
kc.update(data)?;
|
||||
Ok(kc)
|
||||
}
|
||||
|
||||
pub async fn update(&mut self, data: &str) -> Result<()> {
|
||||
pub fn update(&mut self, data: &str) -> Result<()> {
|
||||
let quit = self.get_config("uda.taskwarrior-tui.keyconfig.quit", data);
|
||||
let refresh = self.get_config("uda.taskwarrior-tui.keyconfig.refresh", data);
|
||||
let go_to_bottom = self.get_config("uda.taskwarrior-tui.keyconfig.go-to-bottom", data);
|
||||
|
@ -125,60 +124,6 @@ impl KeyConfig {
|
|||
let next_tab = self.get_config("uda.taskwarrior-tui.keyconfig.next-tab", data);
|
||||
let previous_tab = self.get_config("uda.taskwarrior-tui.keyconfig.previous-tab", data);
|
||||
|
||||
let (
|
||||
quit,
|
||||
refresh,
|
||||
go_to_bottom,
|
||||
go_to_top,
|
||||
down,
|
||||
up,
|
||||
page_down,
|
||||
page_up,
|
||||
delete,
|
||||
done,
|
||||
start_stop,
|
||||
select,
|
||||
select_all,
|
||||
undo,
|
||||
edit,
|
||||
modify,
|
||||
shell,
|
||||
log,
|
||||
add,
|
||||
annotate,
|
||||
filter,
|
||||
zoom,
|
||||
context_menu,
|
||||
next_tab,
|
||||
previous_tab,
|
||||
) = join!(
|
||||
quit,
|
||||
refresh,
|
||||
go_to_bottom,
|
||||
go_to_top,
|
||||
down,
|
||||
up,
|
||||
page_down,
|
||||
page_up,
|
||||
delete,
|
||||
done,
|
||||
start_stop,
|
||||
select,
|
||||
select_all,
|
||||
undo,
|
||||
edit,
|
||||
modify,
|
||||
shell,
|
||||
log,
|
||||
add,
|
||||
annotate,
|
||||
filter,
|
||||
zoom,
|
||||
context_menu,
|
||||
next_tab,
|
||||
previous_tab,
|
||||
);
|
||||
|
||||
self.quit = quit.unwrap_or(self.quit);
|
||||
self.refresh = refresh.unwrap_or(self.refresh);
|
||||
self.go_to_bottom = go_to_bottom.unwrap_or(self.go_to_bottom);
|
||||
|
@ -246,7 +191,7 @@ impl KeyConfig {
|
|||
}
|
||||
}
|
||||
|
||||
async fn get_config(&self, config: &str, data: &str) -> Option<Key> {
|
||||
fn get_config(&self, config: &str, data: &str) -> Option<Key> {
|
||||
for line in data.split('\n') {
|
||||
if line.starts_with(config) {
|
||||
let line = line.trim_start_matches(config).trim_start().trim_end().to_string();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue