2021-02-24 13:12:13 -05:00
|
|
|
use crate::config::Configuration;
|
2023-01-29 19:19:50 -05:00
|
|
|
use std::fs;
|
|
|
|
|
use std::path::Path;
|
2021-02-24 13:12:13 -05:00
|
|
|
|
2023-01-29 19:19:50 -05:00
|
|
|
pub fn generate_config() {
|
|
|
|
|
let json_file = String::from("config.json");
|
|
|
|
|
if !Path::new(&json_file).exists() {
|
|
|
|
|
let generate = Configuration {
|
|
|
|
|
api_token: Some("".to_string()),
|
|
|
|
|
base_api: "/api/v1".to_string(),
|
|
|
|
|
base_url: "https://gitea.com".to_string(),
|
|
|
|
|
username: Some("gitea".to_string()),
|
|
|
|
|
password: Some("".to_string()),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let json = serde_json::to_string(&generate).unwrap();
|
|
|
|
|
|
|
|
|
|
fs::write(json_file, json).expect("Failed to write file.");
|
|
|
|
|
}
|
|
|
|
|
}
|