Manager: Use early-exit return style to decrease nesting

This commit is contained in:
Riyyi
2022-02-10 14:15:57 +01:00
parent b10711686f
commit 272c728e13
+8 -9
View File
@@ -96,7 +96,7 @@ std::optional<std::string> Package::fetchAurHelper()
"trizen", "trizen",
}; };
for(const auto& helper : helpers) { for (const auto& helper : helpers) {
if (findDependency(helper)) { if (findDependency(helper)) {
return { helper }; return { helper };
} }
@@ -112,17 +112,16 @@ void Package::installOrAurInstall(InstallType type)
std::optional<std::string> aurHelper; std::optional<std::string> aurHelper;
if (type == InstallType::AurInstall) { if (type == InstallType::AurInstall) {
if (m_distro == Distro::Arch) { if (m_distro != Distro::Arch) {
aurHelper = fetchAurHelper();
if (!aurHelper.has_value()) {
fprintf(stderr, "\033[31;1mPackage:\033[0m no supported AUR helper found\n");
return;
}
}
else {
fprintf(stderr, "\033[31;1mPackage:\033[0m AUR is not supported on this distribution\n"); fprintf(stderr, "\033[31;1mPackage:\033[0m AUR is not supported on this distribution\n");
return; return;
} }
aurHelper = fetchAurHelper();
if (!aurHelper.has_value()) {
fprintf(stderr, "\033[31;1mPackage:\033[0m no supported AUR helper found\n");
return;
}
} }
std::string command = ""; std::string command = "";