style: align command match branches

This commit is contained in:
xeruf 2024-08-08 18:16:25 +03:00
parent b62ec6fd39
commit c492d64d9e
1 changed files with 25 additions and 28 deletions

View File

@ -294,7 +294,7 @@ async fn main() {
continue; continue;
}, },
Some(',') => { Some(',') =>
match arg { match arg {
None => { None => {
tasks.get_current_task().map_or_else( tasks.get_current_task().map_or_else(
@ -305,7 +305,6 @@ async fn main() {
} }
Some(arg) => tasks.make_note(arg), Some(arg) => tasks.make_note(arg),
} }
}
Some('>') => { Some('>') => {
tasks.update_state(&arg_default, State::Done); tasks.update_state(&arg_default, State::Done);
@ -325,14 +324,15 @@ async fn main() {
tasks.set_state_filter(arg.map(|s| s.to_string())); tasks.set_state_filter(arg.map(|s| s.to_string()));
} }
Some('!') => match tasks.get_position() { Some('!') =>
None => warn!("First select a task to set its state!"), match tasks.get_position() {
Some(id) => { None => warn!("First select a task to set its state!"),
tasks.set_state_for_with(id, arg_default); Some(id) => {
tasks.set_state_for_with(id, arg_default);
}
} }
},
Some('#') => { Some('#') =>
match arg { match arg {
Some(arg) => tasks.set_tag(arg.to_string()), Some(arg) => tasks.set_tag(arg.to_string()),
None => { None => {
@ -340,37 +340,35 @@ async fn main() {
continue; continue;
} }
} }
}
Some('+') => { Some('+') =>
match arg { match arg {
Some(arg) => tasks.add_tag(arg.to_string()), Some(arg) => tasks.add_tag(arg.to_string()),
None => tasks.clear_filter() None => tasks.clear_filter()
} }
}
Some('-') => { Some('-') =>
match arg { match arg {
Some(arg) => tasks.remove_tag(arg), Some(arg) => tasks.remove_tag(arg),
None => tasks.clear_filter() None => tasks.clear_filter()
} }
}
Some('*') => match arg { Some('*') =>
Some(arg) => { match arg {
if let Ok(num) = arg.parse::<i64>() { Some(arg) => {
tasks.track_at(Timestamp::from(Timestamp::now().as_u64().saturating_add_signed(num))); if let Ok(num) = arg.parse::<i64>() {
} else if let Ok(date) = DateTime::parse_from_rfc3339(arg) { tasks.track_at(Timestamp::from(Timestamp::now().as_u64().saturating_add_signed(num)));
tasks.track_at(Timestamp::from(date.to_utc().timestamp() as u64)); } else if let Ok(date) = DateTime::parse_from_rfc3339(arg) {
} else { tasks.track_at(Timestamp::from(date.to_utc().timestamp() as u64));
warn!("Cannot parse {arg}"); } else {
warn!("Cannot parse {arg}");
}
}
None => {
println!("{}", tasks.times_tracked());
continue;
} }
} }
None => {
println!("{}", tasks.times_tracked());
continue
}
}
Some('.') => { Some('.') => {
let mut dots = 1; let mut dots = 1;
@ -422,7 +420,7 @@ async fn main() {
} }
} }
_ => { _ =>
if Regex::new("^wss?://").unwrap().is_match(&input) { if Regex::new("^wss?://").unwrap().is_match(&input) {
tasks.move_to(None); tasks.move_to(None);
let mut new_relay = relays.keys().find(|key| key.as_str().starts_with(&input)).cloned(); let mut new_relay = relays.keys().find(|key| key.as_str().starts_with(&input)).cloned();
@ -445,7 +443,6 @@ async fn main() {
} else { } else {
tasks.filter_or_create(&input); tasks.filter_or_create(&input);
} }
}
} }
or_print(tasks.print_tasks()); or_print(tasks.print_tasks());
} }