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},
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)),

View file

@ -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,
};

View file

@ -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},
};

View file

@ -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},
};

View file

@ -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,
};