1use crate::client::{Client, HglibError, Runner};
6use crate::{runcommand, MkArg};
7
8pub struct Arg<'a> {
9 pub file: &'a str,
10 pub destrepo: &'a str,
11 pub rev: &'a [&'a str],
12 pub branch: &'a [&'a str],
13 pub base: &'a [&'a str],
14 pub all: bool,
15 pub force: bool,
16 pub typ: &'a str,
17 pub ssh: &'a str,
18 pub remotecmd: &'a str,
19 pub insecure: bool,
20}
21
22impl<'a> Default for Arg<'a> {
23 fn default() -> Self {
24 Self {
25 file: "",
26 destrepo: "",
27 rev: &[],
28 branch: &[],
29 base: &[],
30 all: false,
31 force: false,
32 typ: "",
33 ssh: "",
34 remotecmd: "",
35 insecure: false,
36 }
37 }
38}
39
40impl<'a> Arg<'a> {
41 fn run(&self, client: &mut Client) -> Result<(Vec<u8>, i32), HglibError> {
42 runcommand!(
43 client,
44 "bundle",
45 &[self.file, self.destrepo],
46 "-f",
47 self.force,
48 "-r",
49 self.rev,
50 "-b",
51 self.branch,
52 "--base",
53 self.base,
54 "-a",
55 self.all,
56 "-t",
57 self.typ,
58 "-e",
59 self.ssh,
60 "--remotecmd",
61 self.remotecmd,
62 "-insecure",
63 self.insecure
64 )
65 }
66}
67
68impl Client {
69 pub fn bundle(&mut self, x: Arg) -> Result<bool, HglibError> {
70 HglibError::handle_err(x.run(self))
71 }
72}