introduce workspace

This commit is contained in:
steven-omaha
2023-02-13 19:46:35 +01:00
parent c13233a2f3
commit d7ea6ce708
37 changed files with 90 additions and 68 deletions
+15
View File
@@ -0,0 +1,15 @@
[package]
name = "main"
version = "1.0.0-beta2"
edition = "2021"
description = "declarative package manager for Arch Linux"
license = "GPLv3"
repository = "https://github.com/steven-omaha/pacdef"
[[bin]]
name = "pacdef"
path = "main.rs"
[dependencies]
anyhow = "*"
core = { path = "../core", version = "1.0.0-beta2" }
+34
View File
@@ -0,0 +1,34 @@
use std::process::{ExitCode, Termination};
use anyhow::{Context, Result};
use 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")
}