|
@@ -7,8 +7,10 @@ use crate::lib::{
|
|
action::Action
|
|
action::Action
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+use string_template::Template;
|
|
|
|
|
|
use std::process::Command;
|
|
use std::process::Command;
|
|
|
|
+use std::collections::HashMap;
|
|
|
|
|
|
pub fn run(config: &Config, names: Values<'_>) {
|
|
pub fn run(config: &Config, names: Values<'_>) {
|
|
for name in names {
|
|
for name in names {
|
|
@@ -29,3 +31,31 @@ pub fn run_action(config: &Config, name: String) {
|
|
None => panic!("No known action named \"{}\".", name)
|
|
None => panic!("No known action named \"{}\".", name)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+pub fn run_repository_creation(config: &Config, name: String) {
|
|
|
|
+ let repository = config.repositories.get(&name.to_string());
|
|
|
|
+ match repository {
|
|
|
|
+ Some(repository) => {
|
|
|
|
+ let repository_type_name = &repository.repo_type;
|
|
|
|
+ let repository_type = config.repo_types.get(repository_type_name);
|
|
|
|
+ match repository_type {
|
|
|
|
+ Some(repository_type) => {
|
|
|
|
+ if !repository.disabled {
|
|
|
|
+ let mut options: HashMap<&str, &str> = HashMap::new();
|
|
|
|
+ for (key, value) in &repository.options {
|
|
|
|
+ options.insert(key, value);
|
|
|
|
+ }
|
|
|
|
+ options.insert("location", &repository.location);
|
|
|
|
+ let create_command = Template::new(&repository_type.create);
|
|
|
|
+ Command::new("sh")
|
|
|
|
+ .arg("-c")
|
|
|
|
+ .arg(create_command.render(&options))
|
|
|
|
+ .spawn();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ None => panic!("No known repository type named \"{}\".", repository_type_name)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ None => panic!("No known repository named \"{}\".", name)
|
|
|
|
+ }
|
|
|
|
+}
|