1use std::path::Path;
2
3use crate::CommandError;
4
5#[must_use]
10pub fn new(object: &str) -> Show<'_> {
11 Show::new(object)
12}
13
14#[derive(Debug)]
18pub struct Show<'a> {
19 repo_path: Option<&'a Path>,
20 object: &'a str,
21}
22
23impl<'a> Show<'a> {
24 #[must_use]
25 fn new(object: &'a str) -> Self {
26 Self {
27 repo_path: None,
28 object,
29 }
30 }
31
32 #[must_use]
34 pub fn repo_path(mut self, path: &'a Path) -> Self {
35 self.repo_path = Some(path);
36 self
37 }
38
39 #[must_use]
41 pub fn stdout(self) -> cmd_proc::Capture {
42 self.build().stdout()
43 }
44
45 pub fn output(self) -> Result<cmd_proc::Output, CommandError> {
49 self.build().output()
50 }
51
52 fn build(self) -> cmd_proc::Command {
53 crate::base_command(self.repo_path)
54 .argument("show")
55 .argument(self.object)
56 }
57}
58
59#[cfg(feature = "test-utils")]
60impl Show<'_> {
61 pub fn test_eq(&self, other: &cmd_proc::Command) {
63 let command = Self {
64 repo_path: self.repo_path,
65 object: self.object,
66 }
67 .build();
68 command.test_eq(other);
69 }
70}