use super::platform::CodebergPlatform;
use crate::{
config::GitMoverConfig, config_password_wrap, config_value_wrap, errors::GitMoverError,
};
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize, Default, Debug, Clone)]
pub struct CodebergConfig {
pub username: Option<String>,
pub token: Option<String>,
}
impl CodebergConfig {
pub fn get_plateform(config: &mut GitMoverConfig) -> Result<CodebergPlatform, GitMoverError> {
let username = config_value_wrap!(
config,
codeberg,
CodebergConfig,
username,
"your codeberg username"
);
let token = config_password_wrap!(
config,
codeberg,
CodebergConfig,
token,
"your codeberg token (https://codeberg.org/user/settings/applications)"
);
Ok(CodebergPlatform::new(username, token))
}
}