1use crate::client::{Client, HglibError, Runner};
6use crate::{runcommand, MkArg};
7
8pub struct Arg<'a> {
9 pub source: &'a str,
10 pub dest: &'a str,
11 pub after: bool,
12 pub force: bool,
13 pub dryrun: bool,
14 pub include: &'a [&'a str],
15 pub exclude: &'a [&'a str],
16}
17
18impl<'a> Default for Arg<'a> {
19 fn default() -> Self {
20 Self {
21 source: "",
22 dest: "",
23 after: false,
24 force: false,
25 dryrun: false,
26 include: &[],
27 exclude: &[],
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 "move",
37 &[self.source, self.dest],
38 "-A",
39 self.after,
40 "-f",
41 self.force,
42 "-n",
43 self.dryrun,
44 "-I",
45 self.include,
46 "-X",
47 self.exclude
48 )
49 }
50}
51
52impl Client {
53 pub fn r#move(&mut self, x: Arg) -> Result<bool, HglibError> {
54 HglibError::handle_err(x.run(self))
55 }
56}