namespace Build.Commands; public static class FlatpakSourceExtensions { /// The state of AI Studio which goes into the Flatpak. extension(FlatpakSource source) { /// /// The name of the source for the option --source. /// public string Name => source switch { FlatpakSource.MAIN => "main", FlatpakSource.PULL_REQUEST => "pr", FlatpakSource.LOCAL => "local", _ => string.Empty, }; /// /// What the source builds, and what for. /// public string Description => source switch { FlatpakSource.MAIN => "main of MindWorkAI/AI-Studio, to simulate a pre-release", FlatpakSource.PULL_REQUEST => "a pull request of MindWorkAI/AI-Studio, to test its changes early", FlatpakSource.LOCAL => "this local checkout with its uncommitted changes, to test work before there is a pull request", _ => string.Empty, }; /// /// All sources the command offers, in the order of its menu. /// public static IReadOnlyList All => [FlatpakSource.MAIN, FlatpakSource.PULL_REQUEST, FlatpakSource.LOCAL]; /// /// Finds the source for its name. /// /// The name of the source, as the option --source takes it. /// The source, or NONE for an unknown name. public static FlatpakSource FromName(string name) => FlatpakSource.All.FirstOrDefault(candidate => string.Equals(candidate.Name, name.Trim(), StringComparison.OrdinalIgnoreCase)); } }