hglib/commands/
identify.rs1use crate::client::{Client, HglibError, Runner};
6use crate::{runcommand, MkArg};
7
8pub struct Arg<'a> {
9 pub rev: &'a str,
10 pub source: &'a str,
11 pub num: bool,
12 pub id: bool,
13 pub branch: bool,
14 pub tags: bool,
15 pub bookmarks: bool,
16}
17
18impl<'a> Default for Arg<'a> {
19 fn default() -> Self {
20 Self {
21 rev: "",
22 source: "",
23 num: false,
24 id: false,
25 branch: false,
26 tags: false,
27 bookmarks: false,
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 "identify",
37 &[self.source],
38 "-r",
39 self.rev,
40 "-n",
41 self.num,
42 "-i",
43 self.id,
44 "-b",
45 self.branch,
46 "-t",
47 self.tags,
48 "-B",
49 self.bookmarks
50 )
51 }
52}
53
54impl Client {
55 pub fn identify(&mut self, x: Arg) -> Result<Vec<u8>, HglibError> {
56 let (data, _) = x.run(self)?;
57 Ok(data)
58 }
59}