diff --git a/Cargo.toml b/Cargo.toml index a139b1a..7f45445 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ repository = "https://git.pleshevski.ru/pleshevskiy/tas" version = "0.1.0" edition = "2021" license = "GPL-3.0+" +default-run = "tas" [badges] maintenance = { status = "experimental" } @@ -17,3 +18,5 @@ serde = { version = "1.0.142", features = ["derive"] } serde_json = "1.0.83" time = "0.3" xdg = "2.4.1" + + diff --git a/src/bin/fs_to_sqlite.rs b/src/bin/fs_to_sqlite.rs new file mode 100644 index 0000000..3501306 --- /dev/null +++ b/src/bin/fs_to_sqlite.rs @@ -0,0 +1,26 @@ +use tas::repo::{self, Repository}; +use xdg::BaseDirectories; + +fn main() { + let xdg_dirs = BaseDirectories::with_prefix(env!("CARGO_PKG_NAME")).unwrap(); + let fs_repo = repo::fs::FsRepo::new(xdg_dirs.clone()); + let tasks = fs_repo.get_tasks().unwrap(); + + let sqlite_repo = repo::sqlite::SqliteRepo::new(xdg_dirs).unwrap(); + for task in tasks { + log::info!("task: {}", task.name); + log::info!(" inserting..."); + + sqlite_repo + .insert_task(repo::InsertTaskData { + name: task.name, + project: task.project, + link: task.link, + dir_path: task.dir_path, + index: None, + }) + .unwrap(); + + log::info!(" inserted"); + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..7435596 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,2 @@ +pub mod domain; +pub mod repo; diff --git a/src/repo/sqlite.rs b/src/repo/sqlite.rs index 022713b..ba299f1 100644 --- a/src/repo/sqlite.rs +++ b/src/repo/sqlite.rs @@ -132,8 +132,6 @@ impl Repository for SqliteRepo { )) .map_err(|_| Error::InsertData)?; - dbg!(id); - self.get_task_by_id_impl(id).map(From::from) }