git_bonsai/
batchappui.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 */
19use crate::appui::{AppUi, BranchToDeleteInfo};
20use crate::tui;
21
22pub struct BatchAppUi;
23
24impl AppUi for BatchAppUi {
25    fn log_info(&self, msg: &str) {
26        tui::log_info(msg);
27    }
28
29    fn log_warning(&self, msg: &str) {
30        tui::log_warning(msg);
31    }
32
33    fn log_error(&self, msg: &str) {
34        tui::log_error(msg);
35    }
36
37    fn select_branches_to_delete(
38        &self,
39        branch_infos: &[BranchToDeleteInfo],
40    ) -> Vec<BranchToDeleteInfo> {
41        branch_infos.to_vec()
42    }
43
44    fn select_identical_branches_to_delete(&self, branches: &[String]) -> Vec<String> {
45        branches.to_vec()
46    }
47
48    fn select_identical_branches_to_delete_keep_one(&self, branches: &[String]) -> Vec<String> {
49        let mut to_delete = branches.to_vec();
50        to_delete.sort();
51        to_delete.remove(0);
52        to_delete
53    }
54
55    fn select_default_branch(&self, _branches: &[String]) -> Option<String> {
56        None
57    }
58}