Initial commit

This commit is contained in:
Ella Dunbar 2025-07-13 10:13:49 -05:00
commit 1f3ea50d6a
6 changed files with 67 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

7
Cargo.lock generated Normal file
View file

@ -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"

6
Cargo.toml Normal file
View file

@ -0,0 +1,6 @@
[package]
name = "package-manager"
version = "0.1.0"
edition = "2024"
[dependencies]

18
src/lib.rs Normal file
View file

@ -0,0 +1,18 @@
use std::ffi::OsString;
pub mod pacman;
pub struct Package {
pub repository: Vec<String>,
pub name: String,
pub version: String,
pub description: Option<String>,
}
pub trait Manager {
fn command_name(&self) -> OsString;
fn command_exists(&self) -> Result<(), &str>
where
Self: Sized;
fn remote_search(&self, query: &str) -> Result<Vec<Package>, &str>;
}

6
src/main.rs Normal file
View file

@ -0,0 +1,6 @@
use package_manager::{Manager, pacman::*};
fn main() {
let m = Pacman;
print!("{:?}", m.manager_path().unwrap());
}

29
src/pacman/mod.rs Normal file
View file

@ -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<Vec<Package>, &str> {
let output = Command::new
}
}