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