style(main): consistent brace omittal

This commit is contained in:
xeruf 2025-01-29 23:06:42 +01:00
parent 807df3069a
commit a7c6cf2f59

View file

@ -22,7 +22,7 @@ use rustyline::error::ReadlineError;
use rustyline::DefaultEditor; use rustyline::DefaultEditor;
use std::collections::{HashMap, VecDeque}; use std::collections::{HashMap, VecDeque};
use std::env; use std::env;
use std::env::{args}; use std::env::args;
use std::fs; use std::fs;
use std::fs::File; use std::fs::File;
use std::io::{BufRead, BufReader, Write}; use std::io::{BufRead, BufReader, Write};
@ -469,7 +469,7 @@ async fn main() -> Result<()> {
if tasks.custom_time.is_none() { tasks.move_up(); } if tasks.custom_time.is_none() { tasks.move_up(); }
} }
Some('&') => { Some('&') =>
match arg { match arg {
None => tasks.undo(), None => tasks.undo(),
Some(text) => { Some(text) => {
@ -506,9 +506,8 @@ async fn main() -> Result<()> {
} }
} }
} }
}
Some('@') => { Some('@') =>
match arg { match arg {
None => { None => {
let today = Timestamp::now() - 80_000; let today = Timestamp::now() - 80_000;
@ -538,10 +537,9 @@ async fn main() -> Result<()> {
} }
} }
} }
}; }
}
Some('*') => { Some('*') =>
match arg { match arg {
None => match tasks.get_position() { None => match tasks.get_position() {
None => { None => {
@ -565,7 +563,6 @@ async fn main() -> Result<()> {
} }
} }
} }
}
Some('|') => Some('|') =>
match arg { match arg {
@ -590,13 +587,12 @@ async fn main() -> Result<()> {
} }
} }
Some('?') => { Some('?') =>
match arg { match arg {
None => tasks.set_state_filter(StateFilter::Default), None => tasks.set_state_filter(StateFilter::Default),
Some("?") => tasks.set_state_filter(StateFilter::All), Some("?") => tasks.set_state_filter(StateFilter::All),
Some(arg) => tasks.set_state_filter(StateFilter::State(arg.to_string())), Some(arg) => tasks.set_state_filter(StateFilter::State(arg.to_string())),
} }
}
Some('!') => Some('!') =>
match tasks.get_position() { match tasks.get_position() {
@ -631,11 +627,10 @@ async fn main() -> Result<()> {
} }
} }
Some('#') => { Some('#') =>
if !tasks.update_tags(arg_default.split_whitespace().map(Hashtag::from)) { if !tasks.update_tags(arg_default.split_whitespace().map(Hashtag::from)) {
continue; continue;
} }
}
Some('+') => Some('+') =>
match arg { match arg {
@ -681,7 +676,7 @@ async fn main() -> Result<()> {
continue 'repl; continue 'repl;
} }
Some(')') => { Some(')') =>
match arg { match arg {
None => tasks.move_to(None), None => tasks.move_to(None),
Some(arg) => { Some(arg) => {
@ -693,7 +688,6 @@ async fn main() -> Result<()> {
continue 'repl; continue 'repl;
} }
} }
}
Some('.') => { Some('.') => {
let (remaining, dots) = trim_start_count(&command, '.'); let (remaining, dots) = trim_start_count(&command, '.');
@ -722,46 +716,47 @@ async fn main() -> Result<()> {
} }
} }
Some('/') => if arg.is_none() { Some('/') =>
tasks.move_to(None); if arg.is_none() {
} else { tasks.move_to(None);
let (remaining, dots) = trim_start_count(&command, '/');
let pos = tasks.up_by(dots - 1);
if remaining.is_empty() {
tasks.move_to(pos);
if dots > 1 {
info!("Moving up {} tasks", dots - 1)
}
} else if let Ok(depth) = remaining.parse::<usize>() {
if pos != tasks.get_position() {
tasks.move_to(pos);
}
tasks.set_search_depth(depth);
} else { } else {
// TODO regex match let (remaining, dots) = trim_start_count(&command, '/');
let mut transform: Box<dyn Fn(&str) -> String> = Box::new(|s: &str| s.to_string()); let pos = tasks.up_by(dots - 1);
if !remaining.chars().any(|c| c.is_ascii_uppercase()) {
// Smart-case - case-sensitive if any uppercase char is entered
transform = Box::new(|s| s.to_ascii_lowercase());
}
let filtered = if remaining.is_empty() {
tasks.get_filtered(pos, |t| {
transform(&t.get_title()).contains(&remaining) ||
t.list_hashtags().any(
|tag| tag.contains(&remaining))
});
if filtered.len() == 1 {
tasks.move_to(filtered.into_iter().next());
} else {
tasks.move_to(pos); tasks.move_to(pos);
if !tasks.set_view(filtered) { if dots > 1 {
continue 'repl; info!("Moving up {} tasks", dots - 1)
}
} else if let Ok(depth) = remaining.parse::<usize>() {
if pos != tasks.get_position() {
tasks.move_to(pos);
}
tasks.set_search_depth(depth);
} else {
// TODO regex match
let mut transform: Box<dyn Fn(&str) -> String> = Box::new(|s: &str| s.to_string());
if !remaining.chars().any(|c| c.is_ascii_uppercase()) {
// Smart-case - case-sensitive if any uppercase char is entered
transform = Box::new(|s| s.to_ascii_lowercase());
}
let filtered =
tasks.get_filtered(pos, |t| {
transform(&t.get_title()).contains(&remaining) ||
t.list_hashtags().any(
|tag| tag.contains(&remaining))
});
if filtered.len() == 1 {
tasks.move_to(filtered.into_iter().next());
} else {
tasks.move_to(pos);
if !tasks.set_view(filtered) {
continue 'repl;
}
} }
} }
} }
}
_ => _ =>
if Regex::new("^wss?://").unwrap().is_match(command.trim()) { if Regex::new("^wss?://").unwrap().is_match(command.trim()) {