Skip to content

Commit

Permalink
refactor: move switching code into a real crate
Browse files Browse the repository at this point in the history
  • Loading branch information
c-git committed Dec 21, 2024
1 parent c64de4c commit 7081310
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 14 deletions.
213 changes: 213 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"crates/chat-app-client",
"crates/chat-app-server",
"crates/db-types",
"crates/plugin-chat",
"crates/plugin-chat", "crates/switch-db-lib",
"crates/tracked-cancellations",
"crates/ws-auth",
"crates/wykies-client-core",
Expand Down
11 changes: 11 additions & 0 deletions crates/switch-db-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "switch-db-lib"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.94"
clap = { version = "4.5.23", features = ["derive", "wrap_help"] }
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
version-control-clean-check = { version = "0.1.4", features = ["clap"] }
15 changes: 2 additions & 13 deletions scripts/switch_chat_db.rs → crates/switch-db-lib/src/lib.rs
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
#!/usr/bin/env -S cargo +nightly -Zscript
---cargo
package.edition = "2021" # Desirable to stop warning but not needed
[dependencies]
version-control-clean-check = { version = "0.1.4", features = ["clap"] }
anyhow = "1.0.94"
clap = { version = "4.5.23", features = ["derive", "wrap_help"] }
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
---

use anyhow::Context;
use clap::{Parser, ValueEnum};
use std::{
Expand Down Expand Up @@ -46,7 +35,7 @@ struct Cli {
check_version_control: CheckOptions,
}

fn main() -> anyhow::Result<()> {
pub fn run() -> anyhow::Result<()> {
let cli = Cli::parse();

tracing_subscriber::registry()
Expand Down Expand Up @@ -139,7 +128,7 @@ fn switch_sqlx_prepared_queries(path: &Path, db: &Mode) -> anyhow::Result<()> {
// Empty base folder
// TODO: Do a check on source folder for expected files
// TODO: DO a check on base folder if it exists for the expected files

todo!()
}

Expand Down
11 changes: 11 additions & 0 deletions scripts/switch_db.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env -S cargo +nightly -Zscript
---cargo
package.edition = "2021"
[dependencies]
switch-db-lib ={version = "*", path = "../crates/switch-db-lib"}
anyhow = "1.0.94"
---

fn main() -> anyhow::Result<()> {
switch_db_lib::run()
}

0 comments on commit 7081310

Please sign in to comment.