mirror of
https://github.com/nukesor/pueue
synced 2024-10-02 22:13:56 +00:00
fix: panic on 'status -g name' with non-existant group name
This commit is contained in:
parent
69fdf80d13
commit
4d8ce95bab
|
@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||
- Recover tasks from `Locked` state if editing fails [#267](https://github.com/Nukesor/pueue/issues/267)
|
||||
- `pueue log` now behaves the same for local and remote logs.
|
||||
Remote logs previously showed more lines under some circumstances.
|
||||
- panic due to rogue `.unwrap()` when filtering for a non-existing group in `pueue status`.
|
||||
|
||||
## [1.0.5] - 2022-01-02
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ use crate::cli::SubCommand;
|
|||
pub fn print_state(state: State, cli_command: &SubCommand, colors: &Colors, settings: &Settings) {
|
||||
let (json, group_only) = match cli_command {
|
||||
SubCommand::Status { json, group } => (*json, group.clone()),
|
||||
SubCommand::FormatStatus { group } => (false, group.clone()),
|
||||
_ => panic!("Got wrong Subcommand {cli_command:?} in print_state. This shouldn't happen!"),
|
||||
};
|
||||
|
||||
|
@ -41,16 +42,23 @@ fn print_single_group(
|
|||
settings: &Settings,
|
||||
colors: &Colors,
|
||||
mut sorted_tasks: BTreeMap<String, BTreeMap<usize, Task>>,
|
||||
group: String,
|
||||
group_name: String,
|
||||
) {
|
||||
let group = if let Some(group) = state.groups.get(&group_name) {
|
||||
group
|
||||
} else {
|
||||
eprintln!("There exists no group \"{group_name}\"");
|
||||
return;
|
||||
};
|
||||
|
||||
// Only a single group is requested. Print that group and return.
|
||||
let tasks = sorted_tasks.entry(group.clone()).or_default();
|
||||
let headline = get_group_headline(&group, state.groups.get(&group).unwrap(), colors);
|
||||
println!("{}", headline);
|
||||
let tasks = sorted_tasks.entry(group_name.clone()).or_default();
|
||||
let headline = get_group_headline(&group_name, group, colors);
|
||||
println!("{headline}");
|
||||
|
||||
// Show a message if the requested group doesn't have any tasks.
|
||||
if tasks.is_empty() {
|
||||
println!("Task list is empty. Add tasks with `pueue add -g {group} -- [cmd]`");
|
||||
println!("Task list is empty. Add tasks with `pueue add -g {group_name} -- [cmd]`");
|
||||
return;
|
||||
}
|
||||
print_table(tasks, colors, settings);
|
||||
|
|
Loading…
Reference in a new issue