feat: add database initialization and mode handling logic
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
23
src/main.rs
23
src/main.rs
@@ -159,4 +159,25 @@ fn main() -> Result<(), Error> {
|
|||||||
db_path.push("keep-1.db");
|
db_path.push("keep-1.db");
|
||||||
|
|
||||||
debug!("MAIN: Data directory: {:?}", data_path);
|
debug!("MAIN: Data directory: {:?}", data_path);
|
||||||
debug!("MAIN: DB file: {:?}", db_path);
|
debug!("MAIN: DB file: {:?}", db_path);
|
||||||
|
|
||||||
|
// Ensure data directory exists
|
||||||
|
fs::create_dir_all(&data_path)
|
||||||
|
.with_context(|| format!("Unable to create data directory {:?}", data_path))?;
|
||||||
|
|
||||||
|
// Initialize database
|
||||||
|
let mut conn = db::init(&db_path)?;
|
||||||
|
|
||||||
|
match mode {
|
||||||
|
KeepModes::Save => modes::save::mode_save(&mut cmd, &settings, ids, tags, &mut conn, data_path),
|
||||||
|
KeepModes::Get => modes::get::mode_get(&mut cmd, &settings, ids, tags, &mut conn, data_path),
|
||||||
|
KeepModes::Diff => modes::diff::mode_diff(&mut cmd, &settings, &settings, ids, tags, &mut conn, data_path),
|
||||||
|
KeepModes::List => modes::list::mode_list(&mut cmd, &settings, ids, tags, &mut conn, data_path),
|
||||||
|
KeepModes::Delete => modes::delete::mode_delete(&mut cmd, &settings, &settings, ids, tags, &mut conn, data_path),
|
||||||
|
KeepModes::Update => modes::update::mode_update(&mut cmd, &settings, ids, tags, &mut conn, data_path),
|
||||||
|
KeepModes::Info => modes::info::mode_info(&mut cmd, &settings, ids, tags, &mut conn, data_path),
|
||||||
|
KeepModes::Status => modes::status::mode_status(&mut cmd, &settings, data_path, db_path),
|
||||||
|
KeepModes::Server => modes::server::mode_server(&mut cmd, &settings, &mut conn, data_path),
|
||||||
|
KeepModes::Unknown => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user