bin: add script to migrate from FS implementation

This commit is contained in:
Dmitriy Pleshevskiy 2022-08-20 15:41:22 +03:00
parent b690ee4987
commit aec7116651
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
4 changed files with 31 additions and 2 deletions

View file

@ -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"

26
src/bin/fs_to_sqlite.rs Normal file
View file

@ -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");
}
}

2
src/lib.rs Normal file
View file

@ -0,0 +1,2 @@
pub mod domain;
pub mod repo;

View file

@ -132,8 +132,6 @@ impl Repository for SqliteRepo {
))
.map_err(|_| Error::InsertData)?;
dbg!(id);
self.get_task_by_id_impl(id).map(From::from)
}