genpac 0.1.0

Sandbox for Gentoo ebuild development using bubblewrap
// Copyright (C) 2023 Gokul Das B
// SPDX-License-Identifier: GPL-3.0-or-later
//! Common routines
//!
//! This module defines operations that may be reused across multiple modules. They are all
//! reexported in the root module.

/// Extension to Command
///
/// This extends the `std::process::Command` to log the full command line.
pub trait LogCommand {
    fn log(&self, title: &str);
}

impl LogCommand for std::process::Command {
    fn log(&self, title: &str) {
        let program = self.get_program().to_str().unwrap();
        let args: Vec<_> = self.get_args().map(|x| x.to_str().unwrap()).collect();
        log::debug!("{}: {} {}", title, program, args.join(" "));
    }
}