Skip to content

Commit

Permalink
Add CsvStorage support to CLI & Rust package (gluesql#1437)
Browse files Browse the repository at this point in the history
  • Loading branch information
panarch committed Nov 4, 2023
1 parent 110629e commit 6f60c3d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use {
crate::cli::Cli,
anyhow::Result,
clap::Parser,
csv_storage::CsvStorage,
futures::{
executor::block_on,
stream::{StreamExt, TryStreamExt},
Expand Down Expand Up @@ -54,6 +55,7 @@ enum Storage {
Memory,
Sled,
Json,
Csv,
}

pub fn run() -> Result<()> {
Expand Down Expand Up @@ -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");

Expand Down
2 changes: 2 additions & 0 deletions pkg/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -43,5 +44,6 @@ default = [
"shared-memory-storage",
"sled-storage",
"json-storage",
"csv-storage",
"composite-storage",
]

0 comments on commit 6f60c3d

Please sign in to comment.