feat: add create section
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-05-09 18:00:25 +02:00
parent 0406fbe14d
commit 105ab41f19
3 changed files with 30 additions and 21 deletions

View File

@@ -5,6 +5,7 @@ pub enum Commands {
Quit,
WriteQuit,
Archive,
CreateSection { name: String },
}
impl Commands {
@@ -26,11 +27,14 @@ impl CommandParser {
let parts = prepared.split_whitespace().collect_vec();
match parts.split_first() {
Some((command, _)) => match *command {
Some((command, rest)) => match *command {
"w" | "write" => Some(Commands::Write),
"q" | "quit" => Some(Commands::Quit),
"wq" | "write-quit" => Some(Commands::WriteQuit),
"a" | "archive" => Some(Commands::Archive),
"cs" | "create-section" => rest.first().map(|name| Commands::CreateSection {
name: name.to_string(),
}),
_ => None,
},
None => None,