mirror of
https://github.com/elladunbar/package-manager.git
synced 2025-11-05 12:29:54 -06:00
Initial commit
This commit is contained in:
commit
1f3ea50d6a
6 changed files with 67 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/target
|
||||||
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal 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
6
Cargo.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "package-manager"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
18
src/lib.rs
Normal file
18
src/lib.rs
Normal 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
6
src/main.rs
Normal 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
29
src/pacman/mod.rs
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue