commit 1f3ea50d6a31f0d35ea7f43c9c4881bf983b89f6 Author: Ella Dunbar Date: Sun Jul 13 10:13:49 2025 -0500 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..25571f6 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "package-manager" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..257ae52 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "package-manager" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..ff7761f --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,18 @@ +use std::ffi::OsString; + +pub mod pacman; + +pub struct Package { + pub repository: Vec, + pub name: String, + pub version: String, + pub description: Option, +} + +pub trait Manager { + fn command_name(&self) -> OsString; + fn command_exists(&self) -> Result<(), &str> + where + Self: Sized; + fn remote_search(&self, query: &str) -> Result, &str>; +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..2007038 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,6 @@ +use package_manager::{Manager, pacman::*}; + +fn main() { + let m = Pacman; + print!("{:?}", m.manager_path().unwrap()); +} diff --git a/src/pacman/mod.rs b/src/pacman/mod.rs new file mode 100644 index 0000000..450191d --- /dev/null +++ b/src/pacman/mod.rs @@ -0,0 +1,29 @@ +use crate::*; +use std::str::FromStr; +use std::{ffi::OsString, process::Command}; + +pub struct Pacman; + +impl Manager for Pacman { + fn command_name(&self) -> OsString { + return OsString::from_str("pacman").unwrap(); + } + fn command_exists(&self) -> Result<(), &str> + where + Self: Sized { + let output = Command::new("which").arg("pacman").output(); + match output { + Ok(output) => { + if output.status.success() { + return Ok(()); + } else { + return Err("pacman could not be found in path."); + } + } + Err(_) => return Err("Existence check could not be run."), + } + } + fn remote_search(&self, query: &str) -> Result, &str> { + let output = Command::new + } +}