hglib/commands/
bookmark.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 name: &'a str,
10    pub rev: &'a str,
11    pub force: bool,
12    pub delete: bool,
13    pub inactive: bool,
14    pub rename: &'a str,
15}
16
17impl<'a> Default for Arg<'a> {
18    fn default() -> Self {
19        Self {
20            name: "",
21            rev: "",
22            force: false,
23            delete: false,
24            inactive: false,
25            rename: "",
26        }
27    }
28}
29
30impl<'a> Arg<'a> {
31    fn run(&self, client: &mut Client) -> Result<(Vec<u8>, i32), HglibError> {
32        runcommand!(
33            client,
34            "bookmark",
35            &[self.name],
36            "-r",
37            self.rev,
38            "-f",
39            self.force,
40            "-d",
41            self.delete,
42            "-i",
43            self.inactive,
44            "-m",
45            self.rename
46        )
47    }
48}
49
50impl Client {
51    pub fn bookmark(&mut self, x: Arg) -> Result<(), HglibError> {
52        x.run(self)?;
53        Ok(())
54    }
55}