1use std::path::Path;
2
3#[must_use]
5pub fn new() -> Status<'static> {
6 Status::new()
7}
8
9#[derive(Debug)]
13pub struct Status<'a> {
14 repo_path: Option<&'a Path>,
15 porcelain: bool,
16}
17
18crate::impl_repo_path!(Status);
19crate::impl_porcelain!(Status);
20
21impl<'a> Status<'a> {
22 #[must_use]
23 fn new() -> Self {
24 Self {
25 repo_path: None,
26 porcelain: false,
27 }
28 }
29}
30
31impl Default for Status<'_> {
32 fn default() -> Self {
33 Self::new()
34 }
35}
36
37impl crate::Build for Status<'_> {
38 fn build(self) -> cmd_proc::Command {
39 crate::base_command(self.repo_path)
40 .argument("status")
41 .optional_flag(self.porcelain, "--porcelain")
42 }
43}
44
45#[cfg(feature = "test-utils")]
46impl Status<'_> {
47 pub fn test_eq(&self, other: &cmd_proc::Command) {
49 let command = crate::Build::build(Self {
50 repo_path: self.repo_path,
51 porcelain: self.porcelain,
52 });
53 command.test_eq(other);
54 }
55}
56
57#[cfg(test)]
58mod tests {
59 use super::*;
60 use crate::Build;
61
62 #[test]
63 fn test_status() {
64 let output = Status::new().build().capture_stdout().string().unwrap();
65 let _ = output;
67 }
68
69 #[test]
70 fn test_status_porcelain() {
71 let output = Status::new()
72 .porcelain()
73 .build()
74 .capture_stdout()
75 .string()
76 .unwrap();
77 let _ = output;
79 }
80}