1#[must_use]
3pub fn new() -> ShowRef<'static> {
4 ShowRef::new()
5}
6
7#[derive(Debug)]
11pub struct ShowRef<'a> {
12 base: crate::RepoBase<'a>,
13 verify: bool,
14 pattern: Option<&'a str>,
15}
16
17crate::impl_repo_base!(ShowRef);
18
19impl<'a> ShowRef<'a> {
20 #[must_use]
21 fn new() -> Self {
22 Self {
23 base: crate::RepoBase::default(),
24 verify: false,
25 pattern: None,
26 }
27 }
28
29 crate::flag_methods! {
30 pub fn verify / verify_if, verify, "Conditionally enable strict reference checking."
34 }
35
36 #[must_use]
38 pub fn pattern(mut self, pattern: &'a str) -> Self {
39 self.pattern = Some(pattern);
40 self
41 }
42}
43
44impl Default for ShowRef<'_> {
45 fn default() -> Self {
46 Self::new()
47 }
48}
49
50impl crate::Build for ShowRef<'_> {
51 fn build(self) -> Result<cmd_proc::Command, crate::EnvError> {
52 Ok(self
53 .base
54 .command()?
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 base: self.base,
67 verify: self.verify,
68 pattern: self.pattern,
69 })
70 .unwrap();
71 command.test_eq(other);
72 }
73}