Add: add template for notes support
This commit is contained in:
parent
21e08b17ce
commit
ddc8d65169
5 changed files with 70 additions and 1 deletions
21
src/cli.rs
21
src/cli.rs
|
|
@ -25,6 +25,9 @@ pub enum Commands {
|
||||||
|
|
||||||
/// Work with user git projects
|
/// Work with user git projects
|
||||||
Project(ProjectsCommand),
|
Project(ProjectsCommand),
|
||||||
|
|
||||||
|
/// Notes for projects
|
||||||
|
Notes(NotesCommand),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
|
|
@ -87,3 +90,21 @@ pub enum ProjectsAction {
|
||||||
/// List of all user projects
|
/// List of all user projects
|
||||||
List,
|
List,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Args)]
|
||||||
|
pub struct NotesCommand {
|
||||||
|
#[command(subcommand)]
|
||||||
|
pub action: NotesAction,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub enum NotesAction {
|
||||||
|
/// Add project note
|
||||||
|
Add,
|
||||||
|
|
||||||
|
/// Remove project note
|
||||||
|
Remove,
|
||||||
|
|
||||||
|
/// List of all project notes
|
||||||
|
List,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::notes::Note;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
|
@ -7,6 +10,7 @@ pub struct Config {
|
||||||
pub timer_concentrate_mins: u8,
|
pub timer_concentrate_mins: u8,
|
||||||
pub timer_rest_mins: u8,
|
pub timer_rest_mins: u8,
|
||||||
pub projects: Vec<PathBuf>,
|
pub projects: Vec<PathBuf>,
|
||||||
|
pub notes: Vec<Note>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
|
@ -16,6 +20,7 @@ impl Config {
|
||||||
timer_concentrate_mins: 45,
|
timer_concentrate_mins: 45,
|
||||||
timer_rest_mins: 15,
|
timer_rest_mins: 15,
|
||||||
projects: Vec::new(),
|
projects: Vec::new(),
|
||||||
|
notes: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
src/lib.rs
16
src/lib.rs
|
|
@ -2,6 +2,7 @@ mod cli;
|
||||||
mod config;
|
mod config;
|
||||||
mod core;
|
mod core;
|
||||||
mod misc;
|
mod misc;
|
||||||
|
mod notes;
|
||||||
mod projects;
|
mod projects;
|
||||||
mod templates;
|
mod templates;
|
||||||
mod timer;
|
mod timer;
|
||||||
|
|
@ -12,7 +13,7 @@ use strfmt::strfmt;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::{fs, process};
|
use std::{fs, process};
|
||||||
|
|
||||||
use cli::{CLI, Commands, PomodoroAction, ProjectsAction, TemplateAction};
|
use cli::{CLI, Commands, NotesAction, PomodoroAction, ProjectsAction, TemplateAction};
|
||||||
use config::{Config, load_config, save_config};
|
use config::{Config, load_config, save_config};
|
||||||
use projects::{commits_info, repository_status};
|
use projects::{commits_info, repository_status};
|
||||||
use templates::{list_templates, load_template};
|
use templates::{list_templates, load_template};
|
||||||
|
|
@ -243,6 +244,19 @@ fn process_command(mut cfg: Config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Some(Commands::Notes(notes_command)) => match notes_command.action {
|
||||||
|
NotesAction::Add => {
|
||||||
|
todo!("Add notes!");
|
||||||
|
}
|
||||||
|
NotesAction::Remove => {
|
||||||
|
todo!("Remove notes!");
|
||||||
|
}
|
||||||
|
NotesAction::List => {
|
||||||
|
todo!("List of notes!");
|
||||||
|
|
||||||
|
// let notes = cfg.notes;
|
||||||
|
}
|
||||||
|
},
|
||||||
None => {
|
None => {
|
||||||
eprintln!("No command provided. Use --help for usage.");
|
eprintln!("No command provided. Use --help for usage.");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
|
|
|
||||||
3
src/notes/mod.rs
Normal file
3
src/notes/mod.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
mod notes;
|
||||||
|
|
||||||
|
pub use notes::Note;
|
||||||
26
src/notes/notes.rs
Normal file
26
src/notes/notes.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct Note {
|
||||||
|
pub project_dir: PathBuf,
|
||||||
|
pub project_note_info: NoteInfo,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Note {
|
||||||
|
pub fn render(&self) -> String {
|
||||||
|
format!(
|
||||||
|
"{}\n\nDescription:\n{}",
|
||||||
|
self.project_note_info.name, self.project_note_info.description
|
||||||
|
)
|
||||||
|
.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct NoteInfo {
|
||||||
|
pub id: u8,
|
||||||
|
pub name: String,
|
||||||
|
pub description: String,
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue