Files
gt/src/generate.rs

21 lines
614 B
Rust
Raw Normal View History

2021-02-24 13:12:13 -05:00
use crate::config::Configuration;
use std::fs;
use std::path::Path;
2021-02-24 13:12:13 -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.");
}
}