feat(config): add ForgeDetails and RepoDetails types

This commit is contained in:
Paul Campbell 2024-04-07 19:41:56 +01:00
parent 634b040708
commit 3ac4894d68

View file

@ -39,7 +39,48 @@ impl Forge {
} }
} }
#[derive(Debug, PartialEq, Eq, Deserialize)] #[derive(Clone)]
pub struct ForgeName(pub String);
impl Display for ForgeName {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
pub struct Hostname(pub String);
pub struct User(pub String);
pub struct ForgeDetails {
pub name: ForgeName,
pub forge_type: ForgeType,
pub hostname: Hostname,
pub user: User,
// API Token
// Private SSH Key Path
}
impl From<(&ForgeName, &Forge)> for ForgeDetails {
fn from(forge: (&ForgeName, &Forge)) -> Self {
Self {
name: forge.0.clone(),
forge_type: forge.1.forge_type.clone(),
hostname: Hostname(forge.1.hostname.clone()),
user: User(forge.1.user.clone()),
}
}
}
#[derive(Clone)]
pub struct RepoName(pub String);
impl Display for RepoName {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
pub struct RepoPath(pub String);
pub struct RepoDetails {
pub name: RepoName,
pub path: RepoPath,
pub forge: ForgeDetails,
}
#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
pub enum ForgeType { pub enum ForgeType {
ForgeJo, ForgeJo,
// Gitea, // Gitea,