Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
chore(entry): start engine from init
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnwriter committed Nov 20, 2023
1 parent 2821399 commit 6e6b5f4
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/engine/integrity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#![allow(dead_code)]

// Todo: implement hash comparing of the file before installation
48 changes: 48 additions & 0 deletions src/engine/pkg_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use serde::{Deserialize, Serialize};

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PackageInfo {
pub package: Package,
pub maintainer: Maintainer,
pub source: Source,
pub bin: Bin,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Package {
pub name: String,
pub version: String,
pub description: String,
pub license: String,
pub conditions: Option<Conditions>,
pub metadata: Metadata,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Conditions {
pub dependencies: Option<Vec<String>>,
pub conflicts: Option<Vec<String>>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Metadata {
pub hash: Option<String>,
pub keywords: Option<Vec<String>>,
pub categories: Option<Vec<String>>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Maintainer {
pub name: String,
pub email: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Source {
pub url: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Bin {
pub name: String,
}
19 changes: 19 additions & 0 deletions src/init.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use clap::Parser;

pub async fn start() {
let cli = crate::engine::args::Cli::parse();

let result = match cli.command {
crate::engine::CommandChoice::Install(pkg_install_args) => {
crate::commands::install::download_pkgs(pkg_install_args).await
}
crate::engine::CommandChoice::Remove(pkg_uninstall_args) => {
crate::commands::uninstall::remove_pkgs(pkg_uninstall_args).await
}
};

if let Err(err) = result {
eprintln!("Error: {}", err);
std::process::exit(1);
}
}

0 comments on commit 6e6b5f4

Please sign in to comment.