Initial commit: apt-wrapper - Simple APT transaction wrapper
- 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)
This commit is contained in:
commit
7aaefb9957
10 changed files with 761 additions and 0 deletions
45
examples/simple_usage.rs
Normal file
45
examples/simple_usage.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
//! 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(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue