From 6f60c3d29db386dcd6e5d5266f0a9f1b05fca67c Mon Sep 17 00:00:00 2001 From: Taehoon Moon Date: Sat, 4 Nov 2023 14:44:31 +0900 Subject: [PATCH] Add CsvStorage support to CLI & Rust package (#1437) --- Cargo.lock | 2 ++ Cargo.toml | 1 + cli/Cargo.toml | 1 + cli/src/lib.rs | 10 ++++++++++ pkg/rust/Cargo.toml | 2 ++ 5 files changed, 16 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index b09d22a51..97ffd9d8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -899,6 +899,7 @@ dependencies = [ "gluesql-cli", "gluesql-composite-storage", "gluesql-core", + "gluesql-csv-storage", "gluesql-idb-storage", "gluesql-json-storage", "gluesql-shared-memory-storage", @@ -917,6 +918,7 @@ dependencies = [ "edit", "futures", "gluesql-core", + "gluesql-csv-storage", "gluesql-json-storage", "gluesql_memory_storage", "gluesql_sled_storage", diff --git a/Cargo.toml b/Cargo.toml index a54f284fe..f56affa51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ memory-storage = { package = "gluesql_memory_storage", path = "./storages/memory shared-memory-storage = { package = "gluesql-shared-memory-storage", path = "./storages/shared-memory-storage", version = "0.14.0" } sled-storage = { package = "gluesql_sled_storage", path = "./storages/sled-storage", version = "0.14.0" } json-storage = { package = "gluesql-json-storage", path = "./storages/json-storage", version = "0.14.0" } +csv-storage = { package = "gluesql-csv-storage", path = "./storages/csv-storage", version = "0.14.0" } composite-storage = { package = "gluesql-composite-storage", path = "./storages/composite-storage", version = "0.14.0" } web-storage = { package = "gluesql-web-storage", path = "./storages/web-storage", version = "0.14.0" } idb-storage = { package = "gluesql-idb-storage", path = "./storages/idb-storage", version = "0.14.0" } diff --git a/cli/Cargo.toml b/cli/Cargo.toml index a79c3b855..dd1510fc8 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -13,6 +13,7 @@ gluesql-core.workspace = true sled-storage.workspace = true memory-storage.workspace = true json-storage.workspace = true +csv-storage.workspace = true clap = { version = "3.2.2", features = ["derive"] } rustyline = "9.1" diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 404e42292..6adb7b3d2 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -9,6 +9,7 @@ use { crate::cli::Cli, anyhow::Result, clap::Parser, + csv_storage::CsvStorage, futures::{ executor::block_on, stream::{StreamExt, TryStreamExt}, @@ -54,6 +55,7 @@ enum Storage { Memory, Sled, Json, + Csv, } pub fn run() -> Result<()> { @@ -85,6 +87,14 @@ pub fn run() -> Result<()> { args.execute, ); } + (Some(path), Some(Storage::Csv), _) => { + println!("[csv-storage] connected to {}", path); + + run( + CsvStorage::new(path).expect("failed to load csv-storage"), + args.execute, + ); + } (Some(path), None, Some(dump_path)) => { let mut storage = SledStorage::new(path).expect("failed to load sled-storage"); diff --git a/pkg/rust/Cargo.toml b/pkg/rust/Cargo.toml index 8a117f205..86489faf2 100644 --- a/pkg/rust/Cargo.toml +++ b/pkg/rust/Cargo.toml @@ -27,6 +27,7 @@ memory-storage = { workspace = true, optional = true } shared-memory-storage = { workspace = true, optional = true } sled-storage = { workspace = true, optional = true } json-storage = { workspace = true, optional = true } +csv-storage = { workspace = true, optional = true } composite-storage = { workspace = true, optional = true } web-storage = { workspace = true, optional = true } idb-storage = { workspace = true, optional = true } @@ -43,5 +44,6 @@ default = [ "shared-memory-storage", "sled-storage", "json-storage", + "csv-storage", "composite-storage", ]