mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-24 14:36:42 +02:00
fix: Use split_once and rc.defaultwidth=0 for column labels
This commit is contained in:
parent
889cb7de63
commit
c81ac43ca6
2 changed files with 12 additions and 2 deletions
|
@ -202,6 +202,7 @@ impl TaskwarriorTui {
|
||||||
let output = std::process::Command::new("task")
|
let output = std::process::Command::new("task")
|
||||||
.arg("rc.color=off")
|
.arg("rc.color=off")
|
||||||
.arg("rc._forcecolor=off")
|
.arg("rc._forcecolor=off")
|
||||||
|
.arg("rc.defaultwidth=0")
|
||||||
.arg("show")
|
.arg("show")
|
||||||
.output()
|
.output()
|
||||||
.context("Unable to run `task show`.")
|
.context("Unable to run `task show`.")
|
||||||
|
|
|
@ -19,6 +19,13 @@ pub fn format_date(dt: NaiveDateTime) -> String {
|
||||||
dt.format("%Y-%m-%d").to_string()
|
dt.format("%Y-%m-%d").to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn split_once(in_string: &str) -> (&str, &str) {
|
||||||
|
let mut splitter = in_string.splitn(2, ' ');
|
||||||
|
let first = splitter.next().unwrap();
|
||||||
|
let second = splitter.next().unwrap();
|
||||||
|
(first, second)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn vague_format_date_time(from_dt: NaiveDateTime, to_dt: NaiveDateTime, with_remainder: bool) -> String {
|
pub fn vague_format_date_time(from_dt: NaiveDateTime, to_dt: NaiveDateTime, with_remainder: bool) -> String {
|
||||||
let to_dt = Local.from_local_datetime(&to_dt).unwrap();
|
let to_dt = Local.from_local_datetime(&to_dt).unwrap();
|
||||||
let from_dt = Local.from_local_datetime(&from_dt).unwrap();
|
let from_dt = Local.from_local_datetime(&from_dt).unwrap();
|
||||||
|
@ -175,6 +182,7 @@ impl TaskReportTable {
|
||||||
} else {
|
} else {
|
||||||
let output = Command::new("task")
|
let output = Command::new("task")
|
||||||
.arg("show")
|
.arg("show")
|
||||||
|
.arg("rc.defaultwidth=0")
|
||||||
.arg(format!("report.{}.columns", report))
|
.arg(format!("report.{}.columns", report))
|
||||||
.output()?;
|
.output()?;
|
||||||
String::from_utf8_lossy(&output.stdout).into_owned()
|
String::from_utf8_lossy(&output.stdout).into_owned()
|
||||||
|
@ -182,7 +190,7 @@ impl TaskReportTable {
|
||||||
|
|
||||||
for line in data.split('\n') {
|
for line in data.split('\n') {
|
||||||
if line.starts_with(format!("report.{}.columns", report).as_str()) {
|
if line.starts_with(format!("report.{}.columns", report).as_str()) {
|
||||||
let column_names = line.split(' ').collect::<Vec<_>>()[1];
|
let column_names = split_once(line).1;
|
||||||
for column in column_names.split(',') {
|
for column in column_names.split(',') {
|
||||||
self.columns.push(column.to_string());
|
self.columns.push(column.to_string());
|
||||||
}
|
}
|
||||||
|
@ -191,13 +199,14 @@ impl TaskReportTable {
|
||||||
|
|
||||||
let output = Command::new("task")
|
let output = Command::new("task")
|
||||||
.arg("show")
|
.arg("show")
|
||||||
|
.arg("rc.defaultwidth=0")
|
||||||
.arg(format!("report.{}.labels", report))
|
.arg(format!("report.{}.labels", report))
|
||||||
.output()?;
|
.output()?;
|
||||||
let data = String::from_utf8_lossy(&output.stdout);
|
let data = String::from_utf8_lossy(&output.stdout);
|
||||||
|
|
||||||
for line in data.split('\n') {
|
for line in data.split('\n') {
|
||||||
if line.starts_with(format!("report.{}.labels", report).as_str()) {
|
if line.starts_with(format!("report.{}.labels", report).as_str()) {
|
||||||
let label_names = line.split(' ').collect::<Vec<_>>()[1];
|
let label_names = split_once(line).1;
|
||||||
for label in label_names.split(',') {
|
for label in label_names.split(',') {
|
||||||
self.labels.push(label.to_string());
|
self.labels.push(label.to_string());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue