forked from janek/mostr
feat(main): trim input strings
This commit is contained in:
parent
5723151cfb
commit
5d6b2a2dcb
15
src/main.rs
15
src/main.rs
|
@ -206,6 +206,7 @@ async fn main() {
|
||||||
|
|
||||||
let mut iter = input.chars();
|
let mut iter = input.chars();
|
||||||
let op = iter.next();
|
let op = iter.next();
|
||||||
|
let arg = input[1..].trim();
|
||||||
match op {
|
match op {
|
||||||
None => {}
|
None => {}
|
||||||
|
|
||||||
|
@ -215,7 +216,7 @@ async fn main() {
|
||||||
tasks.properties.remove(index);
|
tasks.properties.remove(index);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let value = input[2..].to_string();
|
let value = input[2..].trim().to_string();
|
||||||
if tasks.properties.get(index) == Some(&value) {
|
if tasks.properties.get(index) == Some(&value) {
|
||||||
tasks.properties.remove(index);
|
tasks.properties.remove(index);
|
||||||
} else {
|
} else {
|
||||||
|
@ -223,11 +224,10 @@ async fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let prop = &input[1..];
|
let pos = tasks.properties.iter().position(|s| s == arg);
|
||||||
let pos = tasks.properties.iter().position(|s| s == &prop);
|
|
||||||
match pos {
|
match pos {
|
||||||
None => {
|
None => {
|
||||||
tasks.properties.push(prop.to_string());
|
tasks.properties.push(arg.to_string());
|
||||||
}
|
}
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
tasks.properties.remove(i);
|
tasks.properties.remove(i);
|
||||||
|
@ -237,14 +237,13 @@ async fn main() {
|
||||||
},
|
},
|
||||||
|
|
||||||
Some('?') => {
|
Some('?') => {
|
||||||
let arg = &input[1..];
|
|
||||||
tasks.set_state_filter(Some(arg.to_string()).filter(|s| !s.is_empty()));
|
tasks.set_state_filter(Some(arg.to_string()).filter(|s| !s.is_empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Some('-') => tasks.add_note(&input[1..]),
|
Some('-') => tasks.add_note(arg),
|
||||||
|
|
||||||
Some('>') | Some('<') => {
|
Some('>') | Some('<') => {
|
||||||
tasks.update_state(&input[1..], |_| {
|
tasks.update_state(arg, |_| {
|
||||||
Some(if op.unwrap() == '<' {
|
Some(if op.unwrap() == '<' {
|
||||||
State::Closed
|
State::Closed
|
||||||
} else {
|
} else {
|
||||||
|
@ -255,7 +254,7 @@ async fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Some('#') => {
|
Some('#') => {
|
||||||
tasks.add_tag(input[1..].to_string());
|
tasks.add_tag(arg.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
Some('.') => {
|
Some('.') => {
|
||||||
|
|
Loading…
Reference in New Issue