From 4bbbf541a68c0ee7558c8edd2acc11cfddaceb0d Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Sat, 18 Oct 2025 13:44:32 +0300 Subject: [PATCH 1/4] Move cli.rs out of lib.rs --- src/lib.rs | 1 - src/main.rs | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 35466c4..06f2ec4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ use strum_macros::{Display, EnumString}; -pub mod cli; pub mod error; pub mod mermaid_generator; pub mod plantuml_generator; diff --git a/src/main.rs b/src/main.rs index 1ce6216..88ec50e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,13 +3,15 @@ use std::str::FromStr; use clap::ArgMatches; use sqlant::{get_generator, lookup_parser, GeneratorConfigOptions, GeneratorType}; +mod cli; + fn get_arg(args: &ArgMatches, arg_name: &str) -> String { args.get_one::(arg_name).unwrap().to_string() } #[tokio::main] async fn main() { - let args = sqlant::cli::parse(); + let args = cli::parse(); let mut s = lookup_parser( &get_arg(&args, "connection_string"), From c612176e264eeb2429e4eb1b5257d530e9c0405f Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Sat, 22 Nov 2025 10:29:05 +0200 Subject: [PATCH 2/4] Add test-library-no-clap ci step --- .github/workflows/ci.yml | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7cd0e8..6e43641 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,3 +41,60 @@ jobs: - name: Run Docker Image run: docker run --network host sqlant postgresql://user:password@localhost/db + + test-library-no-clap: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Create test project using sqlant as library + run: | + # Create a temporary test project + mkdir -p /tmp/test-sqlant-lib + cd /tmp/test-sqlant-lib + + # Initialize a new Rust project + cargo init --lib + + # Add sqlant as a library dependency (using local path) + cat > Cargo.toml << 'EOF' + [package] + name = "test-sqlant-lib" + version = "0.1.0" + edition = "2021" + + [dependencies] + sqlant = { path = "${{ github.workspace }}", default-features = false } + EOF + + # Create a simple lib.rs that uses sqlant + cat > src/lib.rs << 'EOF' + use sqlant::{GeneratorType, get_generator}; + + pub fn test_use_sqlant() { + let _ = GeneratorType::PlantUML; + } + EOF + + - name: Build test project + run: | + cd /tmp/test-sqlant-lib + cargo build + + - name: Verify clap is not in Cargo.lock + run: | + cd /tmp/test-sqlant-lib + if grep -q "name = \"clap\"" Cargo.lock; then + echo "ERROR: clap found in Cargo.lock when using sqlant as library" + echo "sqlant should not depend on clap when used as a library" + exit 1 + else + echo "SUCCESS: clap is not in Cargo.lock" + fi From 93c996f3ad21bd7dc191868edcd451ed66041ca1 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Sat, 22 Nov 2025 11:17:45 +0200 Subject: [PATCH 3/4] Make clap optional dependency --- Cargo.toml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 69e4d6a..a9d92cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ tinytemplate = "1.2" serde = { version = "1.0", features = ["derive"] } strum = "0.26" strum_macros = "0.26" -clap = "4.1.4" +clap = { version = "4", optional = true } tokio-postgres = "0.7" tokio = { version = "1", features = ["macros", "rt-multi-thread"] } postgres-native-tls = "0.5.0" @@ -28,6 +28,12 @@ opt-level = "z" # Optimize for size. strip = true lto = true +[[bin]] +name = "sqlant" +path = "src/main.rs" +required-features = ["cli"] + [features] -default = ["vendored-tls"] +default = ["vendored-tls", "cli"] vendored-tls = ["native-tls/vendored"] +cli = ["dep:clap"] From 43c8f09de15447a211ac84b7881578701af736f2 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Sat, 22 Nov 2025 11:35:56 +0200 Subject: [PATCH 4/4] Fix copilot comment --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e43641..ebb044d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: # Create a simple lib.rs that uses sqlant cat > src/lib.rs << 'EOF' - use sqlant::{GeneratorType, get_generator}; + use sqlant::GeneratorType; pub fn test_use_sqlant() { let _ = GeneratorType::PlantUML;