Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use strum_macros::{Display, EnumString};

pub mod cli;
pub mod error;
pub mod mermaid_generator;
pub mod plantuml_generator;
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<String>(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"),
Expand Down
Loading