feat: add command for quickly creating an item
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
4ad8120cb5
commit
832587b51d
@ -6,6 +6,7 @@ pub enum Commands {
|
||||
WriteQuit,
|
||||
Archive,
|
||||
CreateSection { name: String },
|
||||
CreateItem { name: String },
|
||||
Edit,
|
||||
|
||||
ShowAll,
|
||||
@ -40,6 +41,9 @@ impl CommandParser {
|
||||
"cs" | "create-section" => rest.first().map(|name| Commands::CreateSection {
|
||||
name: name.to_string(),
|
||||
}),
|
||||
"ci" | "create-item" => Some(Commands::CreateItem {
|
||||
name: rest.join(" ").to_string(),
|
||||
}),
|
||||
"e" | "edit" => Some(Commands::Edit),
|
||||
"show-all" => Some(Commands::ShowAll),
|
||||
"hide-done" => Some(Commands::HideDone),
|
||||
|
@ -6,7 +6,8 @@ use ratatui::{prelude::*, widgets::*};
|
||||
use crate::{
|
||||
command_parser::Commands,
|
||||
commands::{
|
||||
batch::BatchCommand, create_section::CreateSectionCommandExt,
|
||||
batch::BatchCommand, create_item::CreateItemCommandExt,
|
||||
create_section::CreateSectionCommandExt,
|
||||
open_update_item_dialog::OpenUpdateItemDialogCommandExt, toggle_item::ToggleItemCommandExt,
|
||||
update_graph::UpdateGraphCommandExt, Command, IntoCommand,
|
||||
},
|
||||
@ -241,7 +242,7 @@ impl<'a> GraphExplorer<'a> {
|
||||
Commands::CreateSection { name } => {
|
||||
if !name.is_empty() {
|
||||
let mut path = self.get_current_path();
|
||||
path.push(name.replace(" ", "-").replace(".", "-"));
|
||||
path.push(name.replace(".", "-"));
|
||||
|
||||
// self.state
|
||||
// .commander
|
||||
@ -258,6 +259,21 @@ impl<'a> GraphExplorer<'a> {
|
||||
batch.with(cmd.into_command());
|
||||
}
|
||||
}
|
||||
Commands::CreateItem { name } => {
|
||||
if !name.is_empty() {
|
||||
let mut path = self.get_current_path();
|
||||
path.push(name.replace(".", " "));
|
||||
let cmd = self.state.create_item_command().command(
|
||||
&self.inner.root,
|
||||
&path.iter().map(|i| i.as_str()).collect_vec(),
|
||||
name,
|
||||
"",
|
||||
&hyperlog_core::log::ItemState::default(),
|
||||
);
|
||||
|
||||
batch.with(cmd.into_command());
|
||||
}
|
||||
}
|
||||
Commands::Edit => {
|
||||
if let Some(item) = self.get_current_item() {
|
||||
let path = self.get_current_path();
|
||||
|
Loading…
Reference in New Issue
Block a user