rename all crates

This commit is contained in:
Dr. Matthias Ratajczak
2023-02-14 13:12:08 +01:00
parent 7ff9f6384d
commit 610b63e954
42 changed files with 119 additions and 93 deletions
+18
View File
@@ -0,0 +1,18 @@
[package]
name = "pacdef_main"
version = "1.0.0-beta2"
edition = "2021"
description = "main program for pacdef"
license = "GPLv3"
repository = "https://github.com/steven-omaha/pacdef"
readme = "README.md"
keywords = ["package-manager", "linux", "declarative", "cli"]
categories = ["command-line-utilities"]
[[bin]]
name = "pacdef"
path = "main.rs"
[dependencies]
anyhow = "1.0"
pacdef_core = { path = "../pacdef_core", version = "1.0.0-beta2" }
+3
View File
@@ -0,0 +1,3 @@
# pacdef_main
main program for pacdef
+35
View File
@@ -0,0 +1,35 @@
use std::process::{ExitCode, Termination};
use anyhow::{Context, Result};
use pacdef_core as core;
use pacdef_core::{args, Config, Group, Pacdef};
fn main() -> ExitCode {
handle_final_result(main_inner())
}
/// Skip printing the error chain when searching packages yields no results, otherwise report error
/// chain.
fn handle_final_result(result: Result<()>) -> ExitCode {
match result {
Ok(_) => ExitCode::SUCCESS,
Err(ref e) => {
let msg = e.root_cause().to_string();
if msg == core::NO_PACKAGES_FOUND {
ExitCode::FAILURE
} else {
result.report()
}
}
}
}
fn main_inner() -> Result<()> {
let args = args::get();
let config = Config::load().context("loading config file")?;
let groups = Group::load(&config).context("loading groups").unwrap();
let pacdef = Pacdef::new(args, config, groups);
pacdef.run_action_from_arg().context("running action")
}