git_bonsai/
appui.rs

1/*
2 * Copyright 2021 Aurélien Gâteau <mail@agateau.com>
3 *
4 * This file is part of git-bonsai.
5 *
6 * Git-bonsai is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19/**
20 * This module provides a "high-level" interface for the UI
21 */
22use std::collections::HashSet;
23
24#[derive(Clone, Debug)]
25pub struct BranchToDeleteInfo {
26    pub name: String,
27    pub contained_in: HashSet<String>,
28}
29
30pub trait AppUi {
31    fn log_info(&self, msg: &str);
32    fn log_warning(&self, msg: &str);
33    fn log_error(&self, msg: &str);
34
35    fn select_branches_to_delete(
36        &self,
37        branch_infos: &[BranchToDeleteInfo],
38    ) -> Vec<BranchToDeleteInfo>;
39
40    fn select_identical_branches_to_delete(&self, branches: &[String]) -> Vec<String>;
41
42    fn select_identical_branches_to_delete_keep_one(&self, branches: &[String]) -> Vec<String>;
43
44    fn select_default_branch(&self, branches: &[String]) -> Option<String>;
45}