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