- Core transaction API with add_package, resolve, commit, rollback - Version tracking for upgrades/downgrades - Simple package info with FFI conversion functions - Comprehensive error handling - Basic test suite - Clean, minimal implementation (~326 lines total)
45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
//! Simple usage example for APT wrapper
|
|
|
|
use apt_wrapper::{AptTransaction, init, search_packages};
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
println!("=== Simple APT Wrapper Example ===");
|
|
|
|
// Initialize
|
|
init()?;
|
|
println!("✓ APT wrapper initialized");
|
|
|
|
// Search for packages
|
|
let packages = search_packages("vim")?;
|
|
println!("Found {} packages matching 'vim'", packages.len());
|
|
|
|
// Create transaction
|
|
let mut tx = AptTransaction::new()?;
|
|
println!("✓ Created transaction");
|
|
|
|
// Add packages
|
|
tx.add_package("apt")?;
|
|
tx.add_package("curl")?;
|
|
println!("✓ Added packages to transaction");
|
|
|
|
// Resolve dependencies
|
|
tx.resolve()?;
|
|
println!("✓ Dependencies resolved");
|
|
|
|
// Show what would be installed
|
|
println!("Packages in transaction: {:?}", tx.packages());
|
|
|
|
// Note: We don't actually commit in the example to avoid installing packages
|
|
// tx.commit()?;
|
|
// println!("✓ Transaction committed");
|
|
|
|
// If commit failed, you could rollback:
|
|
// tx.rollback()?;
|
|
// println!("✓ Transaction rolled back");
|
|
// println!("Changed packages: {:?}", tx.changed_packages());
|
|
|
|
println!("✓ Transaction ready (not committed in example)");
|
|
|
|
println!("=== Example completed ===");
|
|
Ok(())
|
|
}
|