1use std::path::Path;
2
3#[must_use]
5pub fn new() -> Diff<'static> {
6 Diff::new()
7}
8
9#[derive(Debug)]
13pub struct Diff<'a> {
14 repo_path: Option<&'a Path>,
15 exit_code: bool,
16}
17
18crate::impl_repo_path!(Diff);
19
20impl<'a> Diff<'a> {
21 #[must_use]
22 fn new() -> Self {
23 Self {
24 repo_path: None,
25 exit_code: false,
26 }
27 }
28
29 #[must_use]
35 pub fn exit_code(mut self) -> Self {
36 self.exit_code = true;
37 self
38 }
39}
40
41impl Default for Diff<'_> {
42 fn default() -> Self {
43 Self::new()
44 }
45}
46
47impl crate::Build for Diff<'_> {
48 fn build(self) -> cmd_proc::Command {
49 crate::base_command(self.repo_path)
50 .argument("diff")
51 .optional_flag(self.exit_code, "--exit-code")
52 }
53}