presets for some startingpoints added

This commit is contained in:
Hermes Agent
2026-08-17 06:40:12 +00:00
parent bcc829c7c2
commit 1f9f00ae7a
6 changed files with 1603 additions and 1 deletions

View File

@@ -14,9 +14,14 @@ use crate::model::{
};
use crate::parser::{extract_when_configured, next_occurrence};
mod presets;
pub use presets::Preset;
pub struct Database {
conn: Connection,
path: PathBuf,
new_document: bool,
}
impl Database {
@@ -30,6 +35,7 @@ impl Database {
let mut db = Self {
conn,
path: path.to_owned(),
new_document: !existed,
};
db.migrate()?;
db.seed_defaults()?;

1381
src/db/presets.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -18,7 +18,7 @@ use crossterm::{
execute,
terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
};
use db::Database;
use db::{Database, Preset};
use ratatui::{Terminal, backend::CrosstermBackend};
#[derive(Debug, Parser)]
@@ -34,6 +34,9 @@ struct Args {
/// Populate a new document with representative items
#[arg(long)]
demo: bool,
/// Initialize a new document with a complete example workspace
#[arg(long, value_enum, conflicts_with = "demo")]
preset: Option<Preset>,
/// Import a text or iCalendar (.ics) file, then exit
#[arg(long)]
import: Option<PathBuf>,
@@ -58,6 +61,9 @@ fn main() -> Result<()> {
if args.demo {
db.seed_demo()?;
}
if let Some(preset) = args.preset {
db.apply_preset(preset)?;
}
if let Some(import) = args.import {
let count = db.import_path(&import)?;
println!("Imported {count} item(s) into {}", path.display());