packager/pkgr/src/main.rs

41 lines
930 B
Rust

use crate::commands::Cli;
use crate::process::Process;
use clap::Parser;
use colored::Colorize;
use log::trace;
use std::process::Command;
mod commands;
mod logging;
mod package;
mod process;
mod tmpfs;
mod config;
thread_local! {
static CONFIG: config::Config = config::Config::from_path("/etc/pkgr.toml")
.unwrap_or(config::Config::default());
}
fn main() {
logging::setup_logger().expect("Unable to setup logger.");
#[cfg(not(debug_assertions))]
{
if unsafe { libc::getuid() } != 0 {
use log::error;
error!("pkgr must be run as root.");
std::process::exit(1);
}
}
trace!("Parsing command line arguments...");
let c = Cli::parse();
trace!("Command line arguments: {:?}", c);
trace!("Executing command...");
c.command.execute();
trace!("Command executed.");
trace!("Exiting...");
}