mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 14:32:22 +08:00
👷 gucc: add exec_checked to io_utils
This commit is contained in:
parent
ccc4f6c459
commit
1492d40efe
@ -10,6 +10,7 @@ namespace gucc::utils {
|
||||
auto safe_getenv(const char* env_name) noexcept -> std::string_view;
|
||||
void exec(const std::vector<std::string>& vec) noexcept;
|
||||
auto exec(std::string_view command, bool interactive = false) noexcept -> std::string;
|
||||
auto exec_checked(std::string_view command) noexcept -> bool;
|
||||
void arch_chroot(std::string_view command, std::string_view mountpoint, bool interactive = false) noexcept;
|
||||
auto arch_chroot_checked(std::string_view command, std::string_view mountpoint) noexcept -> bool;
|
||||
|
||||
|
@ -89,6 +89,10 @@ auto exec(std::string_view command, bool interactive) noexcept -> std::string {
|
||||
return result;
|
||||
}
|
||||
|
||||
auto exec_checked(std::string_view command) noexcept -> bool {
|
||||
return utils::exec(command, true) == "0"sv;
|
||||
}
|
||||
|
||||
void arch_chroot(std::string_view command, std::string_view mountpoint, bool interactive) noexcept {
|
||||
// TODO(vnepogodin): refactor to move output into variable and print into log
|
||||
const auto& cmd_formatted = fmt::format(FMT_COMPILE("arch-chroot {} {} 2>>/tmp/cachyos-install.log 2>&1"), mountpoint, command);
|
||||
@ -105,7 +109,7 @@ auto arch_chroot_checked(std::string_view command, std::string_view mountpoint)
|
||||
const auto& cmd_formatted = fmt::format(FMT_COMPILE("arch-chroot {} {} 2>>/tmp/cachyos-install.log 1>/dev/null"), mountpoint, command);
|
||||
|
||||
#ifdef NDEVENV
|
||||
return utils::exec(cmd_formatted, true) == "0";
|
||||
return utils::exec(cmd_formatted, true) == "0"sv;
|
||||
#else
|
||||
spdlog::info("Running with checked arch-chroot: '{}'", cmd_formatted);
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user