hglib/commands/
remove.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this file,
3// You can obtain one at http://mozilla.org/MPL/2.0/.
4
5use crate::client::{Client, HglibError, Runner};
6use crate::{runcommand, MkArg};
7
8pub struct Arg<'a> {
9    pub files: &'a [&'a str],
10    pub after: bool,
11    pub force: bool,
12    pub include: &'a [&'a str],
13    pub exclude: &'a [&'a str],
14}
15
16impl<'a> Default for Arg<'a> {
17    fn default() -> Self {
18        Self {
19            files: &[],
20            after: false,
21            force: false,
22            include: &[],
23            exclude: &[],
24        }
25    }
26}
27
28impl<'a> Arg<'a> {
29    fn run(&self, client: &mut Client) -> Result<(Vec<u8>, i32), HglibError> {
30        runcommand!(
31            client,
32            "remove",
33            self.files,
34            "-A",
35            self.after,
36            "-f",
37            self.force,
38            "-I",
39            self.include,
40            "-X",
41            self.exclude
42        )
43    }
44}
45
46impl Client {
47    pub fn remove(&mut self, x: Arg) -> Result<bool, HglibError> {
48        HglibError::handle_err(x.run(self))
49    }
50}