Merge pull request #500 from kdheepak/show-error-spawn-for-task-shortcut

Show error message when spawn fails for task_shortcut
This commit is contained in:
Dheepak Krishnamurthy 2023-05-30 11:47:53 -04:00 committed by GitHub
commit 13f5680c47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 22 deletions

View file

@ -48,7 +48,7 @@ use tui::{
layout::{Alignment, Constraint, Direction, Layout, Margin, Rect}, layout::{Alignment, Constraint, Direction, Layout, Margin, Rect},
style::{Color, Modifier, Style}, style::{Color, Modifier, Style},
terminal::Frame, terminal::Frame,
text::{Span, Line, Text}, text::{Line, Span, Text},
widgets::{Block, BorderType, Borders, Clear, Gauge, LineGauge, List, ListItem, Paragraph, Wrap}, widgets::{Block, BorderType, Borders, Clear, Gauge, LineGauge, List, ListItem, Paragraph, Wrap},
}; };
@ -1887,7 +1887,8 @@ impl TaskwarriorTui {
for i in cmd.iter().skip(1) { for i in cmd.iter().skip(1) {
command.arg(i); command.arg(i);
} }
if let Ok(child) = command.spawn() { match command.spawn() {
Ok(child) => {
let output = child.wait_with_output(); let output = child.wait_with_output();
match output { match output {
Ok(o) => { Ok(o) => {
@ -1905,8 +1906,8 @@ impl TaskwarriorTui {
} }
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)), None => Err(format!("Unable to run shortcut number {}: shlex::split(`{}`) failed.", s, shell)),

View file

@ -3,7 +3,7 @@ use std::{error::Error, io};
use tui::{ use tui::{
layout::{Constraint, Corner, Direction, Layout}, layout::{Constraint, Corner, Direction, Layout},
style::{Color, Modifier, Style}, style::{Color, Modifier, Style},
text::{Span, Line}, text::{Line, Span},
widgets::{Block, Borders, List, ListItem, ListState}, widgets::{Block, Borders, List, ListItem, ListState},
Terminal, Terminal,
}; };

View file

@ -4,7 +4,7 @@ use tui::{
buffer::Buffer, buffer::Buffer,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
style::{Modifier, Style}, style::{Modifier, Style},
text::{Span, Line, Text}, text::{Line, Span, Text},
widgets::{Block, BorderType, Borders, Clear, Paragraph, Widget}, widgets::{Block, BorderType, Borders, Clear, Paragraph, Widget},
}; };

View file

@ -14,7 +14,7 @@ use tui::{
layout::{Alignment, Rect}, layout::{Alignment, Rect},
style::{Color, Modifier, Style}, style::{Color, Modifier, Style},
symbols, symbols,
text::{Span, Line, Text}, text::{Line, Span, Text},
widgets::{Block, BorderType, Borders, Clear, Paragraph, StatefulWidget, Widget}, widgets::{Block, BorderType, Borders, Clear, Paragraph, StatefulWidget, Widget},
}; };

View file

@ -3,7 +3,7 @@ use tui::{
layout::{Alignment, Constraint, Direction, Layout, Rect}, layout::{Alignment, Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style}, style::{Color, Modifier, Style},
symbols, symbols,
text::{Span, Line}, text::{Line, Span},
widgets::{Block, BorderType, Borders, Cell, LineGauge, Paragraph, Row, Table}, widgets::{Block, BorderType, Borders, Cell, LineGauge, Paragraph, Row, Table},
Frame, Frame,
}; };