This commit is contained in:
figsoda 2022-12-31 20:20:02 -05:00
parent 70c088f374
commit a313c21a8a
6 changed files with 16 additions and 16 deletions

View File

@ -13,7 +13,7 @@
- `--list-fetchers` to list all available fetchers - `--list-fetchers` to list all available fetchers
- `--list-possible-fetchers` to list all fetchers that can be generated without `--fetcher` - `--list-possible-fetchers` to list all fetchers that can be generated without `--fetcher`
- Support for the following fetchers - Support for the following fetchers
- `fetchBitBucket` (<https://bitbucket.org>) - `fetchFromBitbucket` (<https://bitbucket.org>)
- `fetchFromGitea` (and <https://codeberg.org>) - `fetchFromGitea` (and <https://codeberg.org>)
- `fetchFromGitiles` (and <https://googlesource.com>) - `fetchFromGitiles` (and <https://googlesource.com>)
- `fetchFromRepoOrCz` (<https://repo.or.cz>) - `fetchFromRepoOrCz` (<https://repo.or.cz>)

View File

@ -20,7 +20,7 @@ fetchFromGitHub {
## Supported Fetchers ## Supported Fetchers
- fetchFromBitBucket - fetchFromBitbucket
- fetchFromGitHub - fetchFromGitHub
- fetchFromGitLab - fetchFromGitLab
- fetchFromGitea - fetchFromGitea
@ -40,7 +40,7 @@ Arguments:
[REV] the revision or reference to be fetched [REV] the revision or reference to be fetched
Options: Options:
-f, --fetcher <FETCHER> specify the fetcher function instead of inferring from the URL [possible values: fetchFromBitBucket, fetchFromGitHub, fetchFromGitLab, fetchFromGitea, fetchFromGitiles, fetchFromRepoOrCz, fetchFromSourcehut, fetchgit, fetchhg] -f, --fetcher <FETCHER> specify the fetcher function instead of inferring from the URL [possible values: fetchFromBitbucket, fetchFromGitHub, fetchFromGitLab, fetchFromGitea, fetchFromGitiles, fetchFromRepoOrCz, fetchFromSourcehut, fetchgit, fetchhg]
-i, --indent <INDENT> extra indentation (in number of spaces) [default: 0] -i, --indent <INDENT> extra indentation (in number of spaces) [default: 0]
-j, --json output in json format -j, --json output in json format
-a, --arg <KEY> <VALUE> additional arguments to pass to the fetcher -a, --arg <KEY> <VALUE> additional arguments to pass to the fetcher

View File

@ -50,7 +50,7 @@ pub struct Opts {
#[derive(Clone, Debug, ValueEnum)] #[derive(Clone, Debug, ValueEnum)]
#[clap(rename_all = "camelCase")] #[clap(rename_all = "camelCase")]
pub enum FetcherFunction { pub enum FetcherFunction {
FetchFromBitBucket, FetchFromBitbucket,
FetchFromGitHub, FetchFromGitHub,
FetchFromGitLab, FetchFromGitLab,
FetchFromGitea, FetchFromGitea,

View File

@ -3,15 +3,15 @@ use crate::{
simple::{SimpleFetcher, SimpleUrlFetcher}, simple::{SimpleFetcher, SimpleUrlFetcher},
}; };
pub struct FetchFromBitBucket; pub struct FetchFromBitbucket;
impl_fetcher!(FetchFromBitBucket); impl_fetcher!(FetchFromBitbucket);
impl<'a> SimpleFetcher<'a> for FetchFromBitBucket { impl<'a> SimpleFetcher<'a> for FetchFromBitbucket {
const KEYS: [&'static str; 2] = ["owner", "repo"]; const KEYS: [&'static str; 2] = ["owner", "repo"];
const NAME: &'static str = "fetchFromBitBucket"; const NAME: &'static str = "fetchFromBitbucket";
} }
impl<'a> SimpleUrlFetcher<'a> for FetchFromBitBucket { impl<'a> SimpleUrlFetcher<'a> for FetchFromBitbucket {
fn get_url(&self, [owner, repo]: [&str; 2], rev: &str) -> String { fn get_url(&self, [owner, repo]: [&str; 2], rev: &str) -> String {
format!("https://bitbucket.org/{owner}/{repo}/get/{rev}.tar.gz") format!("https://bitbucket.org/{owner}/{repo}/get/{rev}.tar.gz")
} }

View File

@ -8,7 +8,7 @@ mod hg;
mod repo_or_cz; mod repo_or_cz;
mod sourcehut; mod sourcehut;
pub use bitbucket::FetchFromBitBucket; pub use bitbucket::FetchFromBitbucket;
pub use git::Fetchgit; pub use git::Fetchgit;
pub use gitea::FetchFromGitea; pub use gitea::FetchFromGitea;
pub use github::FetchFromGitHub; pub use github::FetchFromGitHub;
@ -45,7 +45,7 @@ pub trait Fetcher {
#[enum_dispatch(Fetcher)] #[enum_dispatch(Fetcher)]
pub enum FetcherDispatch<'a> { pub enum FetcherDispatch<'a> {
FetchFromBitBucket(FetchFromBitBucket), FetchFromBitbucket(FetchFromBitbucket),
FetchFromGitHub(FetchFromGitHub<'a>), FetchFromGitHub(FetchFromGitHub<'a>),
FetchFromGitLab(FetchFromGitLab<'a>), FetchFromGitLab(FetchFromGitLab<'a>),
FetchFromGitea(FetchFromGitea<'a>), FetchFromGitea(FetchFromGitea<'a>),

View File

@ -12,7 +12,7 @@ use itertools::Itertools;
use crate::{ use crate::{
cli::{FetcherFunction, Opts}, cli::{FetcherFunction, Opts},
fetcher::{ fetcher::{
FetchFromBitBucket, FetchFromGitHub, FetchFromGitLab, FetchFromGitea, FetchFromGitiles, FetchFromBitbucket, FetchFromGitHub, FetchFromGitLab, FetchFromGitea, FetchFromGitiles,
FetchFromRepoOrCz, FetchFromSourcehut, Fetcher, FetcherDispatch, Fetchgit, Fetchhg, FetchFromRepoOrCz, FetchFromSourcehut, Fetcher, FetcherDispatch, Fetchgit, Fetchhg,
}, },
}; };
@ -36,11 +36,11 @@ fn main() -> Result<()> {
} }
let fetcher: FetcherDispatch = match (opts.fetcher, opts.url.host_str()) { let fetcher: FetcherDispatch = match (opts.fetcher, opts.url.host_str()) {
(None | Some(FetcherFunction::FetchFromBitBucket), Some("bitbucket.org")) => { (None | Some(FetcherFunction::FetchFromBitbucket), Some("bitbucket.org")) => {
FetchFromBitBucket.into() FetchFromBitbucket.into()
} }
(Some(FetcherFunction::FetchFromBitBucket), _) => { (Some(FetcherFunction::FetchFromBitbucket), _) => {
bail!("fetchFromBitBucket only supports bitbucket.org"); bail!("fetchFromBitbucket only supports bitbucket.org");
} }
(None | Some(FetcherFunction::FetchFromGitHub), Some("github.com")) => { (None | Some(FetcherFunction::FetchFromGitHub), Some("github.com")) => {