feat: generate config, load shell env vars

This commit is contained in:
2023-01-29 19:19:50 -05:00
parent 58b4b00311
commit 7c5c0c13fb
8 changed files with 275 additions and 56 deletions

View File

@@ -1,5 +1,20 @@
use crate::config::Configuration;
use std::fs;
use std::path::Path;
fn generate_config() {
}
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.");
}
}