Community packages were invisible unless the user ran yay/paru by hand. Wrap the helper behind the provider interface, like the Flatpak plugin, so AUR results join search, installed and updates while staying optional. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
61 lines
2.7 KiB
C++
61 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include "package-manager.h"
|
|
|
|
// AUR provider: manages Arch User Repository packages through an AUR helper
|
|
// (`yay` preferred, `paru` fallback). Runs per-user like flatpak for search
|
|
// and list (helpers handle sudo internally for install/remove/update), so
|
|
// requiresPassword() is false — the helper prompts on its own terminal.
|
|
class AurManager : public IPackageManager {
|
|
public:
|
|
std::string getName() const override { return "aur"; }
|
|
std::string getVersion() const override { return "1.0.0"; }
|
|
std::string getDescription() const override {
|
|
return "Paquets communautaires Arch (AUR via yay/paru)";
|
|
}
|
|
|
|
bool canSearch() const override { return true; }
|
|
bool canInstall() const override { return true; }
|
|
bool canRemove() const override { return true; }
|
|
bool canUpdate() const override { return true; }
|
|
bool canListInstalled() const override { return true; }
|
|
|
|
bool isAvailable() const override {
|
|
return !helper().empty();
|
|
}
|
|
|
|
// Last lines of the failed command output, shown to the user on failure.
|
|
std::string lastError() const override { return m_lastError; }
|
|
|
|
// Name of the backing helper binary ("yay", "paru", or empty).
|
|
// Exposed as static so availability can be unit-tested without helpers.
|
|
static std::string helper();
|
|
|
|
// Parse `yay -Ss` output (pairs of "repo/name version" + description
|
|
// line, with ANSI colors stripped) into packages.
|
|
// Exposed as static so the parsing can be unit-tested without yay.
|
|
static std::vector<PackageInfo> parseSearchOutput(const std::string& output);
|
|
|
|
// Parse `yay -Qm` output (one "name version" line per foreign package).
|
|
// Exposed as static so the parsing can be unit-tested without yay.
|
|
static std::vector<PackageInfo> parseInstalledOutput(const std::string& output);
|
|
|
|
// Parse `yay -Qu` output (one "name old -> new" line per outdated pkg).
|
|
// Exposed as static so the parsing can be unit-tested without yay.
|
|
static std::vector<PackageInfo> parseUpdatesOutput(const std::string& output);
|
|
|
|
std::vector<PackageInfo> search(const std::string& query) override;
|
|
bool install(const std::string& packageName,
|
|
ProgressCallback progressCallback) override;
|
|
bool remove(const std::string& packageName,
|
|
ProgressCallback progressCallback) override;
|
|
bool update(const std::string& packageName = "",
|
|
ProgressCallback progressCallback = nullptr) override;
|
|
std::vector<PackageInfo> listInstalled() override;
|
|
std::vector<PackageInfo> listUpdates() override;
|
|
bool refresh(ProgressCallback progressCallback = nullptr) override;
|
|
|
|
private:
|
|
std::string m_lastError;
|
|
};
|