diff options
Diffstat (limited to 'src/sub_commands/fetch.rs')
| -rw-r--r-- | src/sub_commands/fetch.rs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/sub_commands/fetch.rs b/src/sub_commands/fetch.rs deleted file mode 100644 index b1e83c5..0000000 --- a/src/sub_commands/fetch.rs +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 1 | use std::collections::HashSet; | ||
| 2 | |||
| 3 | use anyhow::{Context, Result}; | ||
| 4 | use clap; | ||
| 5 | use nostr::nips::nip01::Coordinate; | ||
| 6 | |||
| 7 | #[cfg(not(test))] | ||
| 8 | use crate::client::Client; | ||
| 9 | #[cfg(test)] | ||
| 10 | use crate::client::MockConnect; | ||
| 11 | use crate::{ | ||
| 12 | cli::Cli, | ||
| 13 | client::{fetching_with_report, Connect}, | ||
| 14 | git::{Repo, RepoActions}, | ||
| 15 | repo_ref::get_repo_coordinates, | ||
| 16 | }; | ||
| 17 | |||
| 18 | #[derive(clap::Args)] | ||
| 19 | pub struct SubCommandArgs { | ||
| 20 | /// address pointer to repo announcement | ||
| 21 | #[arg(long, action)] | ||
| 22 | repo: Vec<String>, | ||
| 23 | } | ||
| 24 | |||
| 25 | pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> { | ||
| 26 | let _ = args; | ||
| 27 | let git_repo = Repo::discover().context("cannot find a git repository")?; | ||
| 28 | #[cfg(not(test))] | ||
| 29 | let client = Client::default(); | ||
| 30 | #[cfg(test)] | ||
| 31 | let client = <MockConnect as std::default::Default>::default(); | ||
| 32 | let repo_coordinates = if command_args.repo.is_empty() { | ||
| 33 | get_repo_coordinates(&git_repo, &client).await? | ||
| 34 | } else { | ||
| 35 | let mut repo_coordinates = HashSet::new(); | ||
| 36 | for repo in &command_args.repo { | ||
| 37 | repo_coordinates.insert(Coordinate::parse(repo.clone())?); | ||
| 38 | } | ||
| 39 | repo_coordinates | ||
| 40 | }; | ||
| 41 | fetching_with_report(git_repo.get_path()?, &client, &repo_coordinates).await?; | ||
| 42 | client.disconnect().await?; | ||
| 43 | Ok(()) | ||
| 44 | } | ||