presets for some startingpoints added
This commit is contained in:
@@ -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
1381
src/db/presets.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user