From 3548fdcf78ebccc16b48e4cdeb6259428446441f Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Tue, 30 May 2023 11:46:34 -0400 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20Show=20error=20message=20when=20spa?= =?UTF-8?q?wn=20fails=20for=20task=5Fshortcut=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.rs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/app.rs b/src/app.rs index 84e2a09..6bddc5d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -48,7 +48,7 @@ use tui::{ layout::{Alignment, Constraint, Direction, Layout, Margin, Rect}, style::{Color, Modifier, Style}, terminal::Frame, - text::{Span, Line, Text}, + text::{Line, Span, Text}, widgets::{Block, BorderType, Borders, Clear, Gauge, LineGauge, List, ListItem, Paragraph, Wrap}, }; @@ -1887,26 +1887,27 @@ impl TaskwarriorTui { for i in cmd.iter().skip(1) { command.arg(i); } - if let Ok(child) = command.spawn() { - let output = child.wait_with_output(); - match output { - Ok(o) => { - if o.status.success() { - Ok(()) - } else { - Err(format!( - "Unable to run shortcut {}. Status Code: {} - stdout: {} stderr: {}", - s, - o.status.code().unwrap_or_default(), - String::from_utf8_lossy(&o.stdout), - String::from_utf8_lossy(&o.stderr), - )) + match command.spawn() { + Ok(child) => { + let output = child.wait_with_output(); + match output { + Ok(o) => { + if o.status.success() { + Ok(()) + } else { + Err(format!( + "Unable to run shortcut {}. Status Code: {} - stdout: {} stderr: {}", + s, + o.status.code().unwrap_or_default(), + String::from_utf8_lossy(&o.stdout), + String::from_utf8_lossy(&o.stderr), + )) + } } + Err(s) => Err(format!("`{}` failed to wait with output: {}", shell, s)), } - Err(s) => Err(format!("`{}` failed to wait with output: {}", shell, s)), } - } else { - Err(format!("`{}` failed: Unable to spawn shortcut number {}", shell, s)) + Err(err) => Err(format!("`{}` failed: Unable to spawn shortcut number {} - Error: {}", shell, s, err)), } } None => Err(format!("Unable to run shortcut number {}: shlex::split(`{}`) failed.", s, shell)), From 594d982bc98defbff7555fce38f9ba99291c6a9d Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Tue, 30 May 2023 11:47:41 -0400 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20cargo=20fmt=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/completion.rs | 2 +- src/help.rs | 2 +- src/pane/context.rs | 2 +- src/ui.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/completion.rs b/src/completion.rs index db75d74..aaa0ba8 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -3,7 +3,7 @@ use std::{error::Error, io}; use tui::{ layout::{Constraint, Corner, Direction, Layout}, style::{Color, Modifier, Style}, - text::{Span, Line}, + text::{Line, Span}, widgets::{Block, Borders, List, ListItem, ListState}, Terminal, }; diff --git a/src/help.rs b/src/help.rs index 49c9eff..f574942 100644 --- a/src/help.rs +++ b/src/help.rs @@ -4,7 +4,7 @@ use tui::{ buffer::Buffer, layout::{Alignment, Rect}, style::{Modifier, Style}, - text::{Span, Line, Text}, + text::{Line, Span, Text}, widgets::{Block, BorderType, Borders, Clear, Paragraph, Widget}, }; diff --git a/src/pane/context.rs b/src/pane/context.rs index a457cf5..f1dbdd8 100644 --- a/src/pane/context.rs +++ b/src/pane/context.rs @@ -14,7 +14,7 @@ use tui::{ layout::{Alignment, Rect}, style::{Color, Modifier, Style}, symbols, - text::{Span, Line, Text}, + text::{Line, Span, Text}, widgets::{Block, BorderType, Borders, Clear, Paragraph, StatefulWidget, Widget}, }; diff --git a/src/ui.rs b/src/ui.rs index c8de8dc..8d38d72 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -3,7 +3,7 @@ use tui::{ layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, symbols, - text::{Span, Line}, + text::{Line, Span}, widgets::{Block, BorderType, Borders, Cell, LineGauge, Paragraph, Row, Table}, Frame, };