blob: 07fd6f929c7ecbca4d02775fd67a11fa95756d97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
use std::collections::HashSet;
use anyhow::{Context, Result};
use clap;
use nostr::nips::nip01::Coordinate;
#[cfg(not(test))]
use crate::client::Client;
#[cfg(test)]
use crate::client::MockConnect;
use crate::{
client::Connect,
git::{Repo, RepoActions},
repo_ref::get_repo_coordinates,
Cli,
};
#[derive(clap::Args)]
pub struct SubCommandArgs {
/// address pointer to repo announcement
#[arg(long, action)]
repo: Vec<String>,
}
pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> {
let _ = args;
let git_repo = Repo::discover().context("cannot find a git repository")?;
#[cfg(not(test))]
let client = Client::default();
#[cfg(test)]
let client = <MockConnect as std::default::Default>::default();
let repo_coordinates = if command_args.repo.is_empty() {
get_repo_coordinates(&git_repo, &client).await?
} else {
let mut repo_coordinates = HashSet::new();
for repo in &command_args.repo {
repo_coordinates.insert(Coordinate::parse(repo.clone())?);
}
repo_coordinates
};
client
.fetch_all(git_repo.get_path()?, &repo_coordinates)
.await?;
client.disconnect().await?;
Ok(())
}
|