mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-23 20:16:41 +02:00
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:
commit
13f5680c47
5 changed files with 23 additions and 22 deletions
37
src/app.rs
37
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)),
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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},
|
||||
};
|
||||
|
||||
|
|
|
@ -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},
|
||||
};
|
||||
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue