using System.Runtime.InteropServices;

namespace Flo.Installer.Provisioning;

internal sealed record Paths(string Install)
{
    public string Postgres      => Path.Combine(Install, "postgres");
    public string FerretDb      => Path.Combine(Install, "ferretdb");
    public string Service       => Path.Combine(Install, "service");
    public string DataRoot      => Path.Combine(Install, "data");
    public string PostgresData  => Path.Combine(DataRoot, "postgres");
    public string FerretDbData  => Path.Combine(DataRoot, "ferretdb");
    public string Logs          => Path.Combine(Install, "logs");
    public string Config        => Path.Combine(Install, "config");
    public string ConfigFile    => Path.Combine(Config, "flo.json");
    public string SecretsFile   => Path.Combine(Install, "secrets", "secrets.json");

    public string PostgresBin(string tool)
    {
        string name = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? $"{tool}.exe" : tool;
        return Path.Combine(Postgres, "bin", name);
    }

    public string FerretDbExe()
        => Path.Combine(FerretDb, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "ferretdb.exe" : "ferretdb");
}
