You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
malachite/src/repository/config.rs

45 lines
1.1 KiB
Rust

use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
2 years ago
use crate::crash;
use crate::internal::AppExitCode;
const DEFAULT_CONFIG: &str = r#"# either "repository" or "workspace"
mode = ""
# only required when in repository mode, decides what to call the repository and relevant files
name = ""
# an array of git repos to clone from, formatted url_index::repo_name, e.g. if you had urls = [ "https://example.com/%repo%" ], 1::package would expand to https://example.com/package
repo = [
"",
""
]
# an array of urls to clone from, in the format https://example.com/%repo% (the %repo% is NOT optional)
urls = [
"",
""
]"#;
pub fn create_config() {
if env::current_dir()
.unwrap()
.read_dir()
.unwrap()
.next()
.is_some()
{
crash!(
AppExitCode::DirNotEmpty,
"Directory is not empty, please only create a repository in an empty directory"
);
}
if !Path::exists("mlc.toml".as_ref()) {
let mut file = File::create("mlc.toml").unwrap();
file.write_all(DEFAULT_CONFIG.as_ref()).unwrap();
}
}