namespace Build.Commands;
public static class FlatpakArchitectureExtensions
{
/// The CPU architecture of the Flatpak.
extension(FlatpakArchitecture architecture)
{
///
/// The name of the architecture in Flatpak and on Linux, as uname -m reports it.
///
public string FlatpakName => architecture switch
{
FlatpakArchitecture.AARCH64 => "aarch64",
FlatpakArchitecture.X86_64 => "x86_64",
_ => string.Empty,
};
///
/// The platform of a Docker image which runs on this architecture.
///
public string DockerPlatform => architecture switch
{
FlatpakArchitecture.AARCH64 => "linux/arm64",
FlatpakArchitecture.X86_64 => "linux/amd64",
_ => string.Empty,
};
///
/// The file name of the bundle of AI Studio, the same as the CI of the Flatpak repository gives it.
///
public string AppBundleName => $"MindWork AI Studio_{architecture.FlatpakName}.flatpak";
///
/// The file name of the bundle of the Pandoc plugin, the same as the CI of the Flatpak repository gives it.
///
public string PandocBundleName => $"MindWork AI Studio Plugin Pandoc_{architecture.FlatpakName}.flatpak";
///
/// Finds the architecture for a name, as Flatpak, Linux, or Docker write it.
///
/// The name, e.g., aarch64, arm64, x86_64, or amd64.
/// The architecture, or NONE for an unknown name.
public static FlatpakArchitecture FromName(string name) => name.Trim().ToLowerInvariant() switch
{
"aarch64" or "arm64" => FlatpakArchitecture.AARCH64,
"x86_64" or "amd64" => FlatpakArchitecture.X86_64,
_ => FlatpakArchitecture.NONE,
};
}
}