1use std::path::Path;
2
3#[must_use]
5pub fn new() -> ShowRef<'static> {
6 ShowRef::new()
7}
8
9#[derive(Debug)]
13pub struct ShowRef<'a> {
14 repo_path: Option<&'a Path>,
15 verify: bool,
16 pattern: Option<&'a str>,
17}
18
19crate::impl_repo_path!(ShowRef);
20
21impl<'a> ShowRef<'a> {
22 #[must_use]
23 fn new() -> Self {
24 Self {
25 repo_path: None,
26 verify: false,
27 pattern: None,
28 }
29 }
30
31 crate::flag_methods! {
32 pub fn verify / verify_if, verify, "Conditionally enable strict reference checking."
36 }
37
38 #[must_use]
40 pub fn pattern(mut self, pattern: &'a str) -> Self {
41 self.pattern = Some(pattern);
42 self
43 }
44}
45
46impl Default for ShowRef<'_> {
47 fn default() -> Self {
48 Self::new()
49 }
50}
51
52impl crate::Build for ShowRef<'_> {
53 fn build(self) -> cmd_proc::Command {
54 crate::base_command(self.repo_path)
55 .argument("show-ref")
56 .optional_flag(self.verify, "--verify")
57 .optional_argument(self.pattern)
58 }
59}
60
61#[cfg(feature = "test-utils")]
62impl ShowRef<'_> {
63 pub fn test_eq(&self, other: &cmd_proc::Command) {
65 let command = crate::Build::build(Self {
66 repo_path: self.repo_path,
67 verify: self.verify,
68 pattern: self.pattern,
69 });
70 command.test_eq(other);
71 }
72}