1use crate::repository::RemoteName;
2
3#[must_use]
5pub fn get_url(name: &RemoteName) -> Remote<'_> {
6 Remote::get_url(name)
7}
8
9#[derive(Debug)]
13pub struct Remote<'a> {
14 base: crate::RepoBase<'a>,
15 subcommand: RemoteSubcommand<'a>,
16}
17
18#[derive(Debug)]
19enum RemoteSubcommand<'a> {
20 GetUrl { name: &'a RemoteName },
21}
22
23crate::impl_repo_base!(Remote);
24
25impl<'a> Remote<'a> {
26 #[must_use]
27 fn get_url(name: &'a RemoteName) -> Self {
28 Self {
29 base: crate::RepoBase::default(),
30 subcommand: RemoteSubcommand::GetUrl { name },
31 }
32 }
33}
34
35impl crate::Build for Remote<'_> {
36 fn build(self) -> Result<cmd_proc::Command, crate::EnvError> {
37 let RemoteSubcommand::GetUrl { name } = self.subcommand;
38
39 Ok(self
40 .base
41 .command()?
42 .argument("remote")
43 .argument("get-url")
44 .argument(name))
45 }
46}
47
48#[cfg(feature = "test-utils")]
49impl Remote<'_> {
50 pub fn test_eq(&self, other: &cmd_proc::Command) {
52 let command = crate::Build::build(Self {
53 base: self.base,
54 subcommand: match &self.subcommand {
55 RemoteSubcommand::GetUrl { name } => RemoteSubcommand::GetUrl { name },
56 },
57 })
58 .unwrap();
59 command.test_eq(other);
60 }
61}