Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f621a46954 | ||
|
|
b18ada61c7 | ||
|
|
c2d6174fc9 | ||
|
|
a37f78a4e7 |
No files matched your search
Whitespace-only changes.
Whitespace-only changes.
+48
-3
@@ -163,6 +163,7 @@ impl AppState {
|
|||||||
new_project.load_config(display)?;
|
new_project.load_config(display)?;
|
||||||
let template_box = self.config.get("template_box").unwrap();
|
let template_box = self.config.get("template_box").unwrap();
|
||||||
let tools = self.config.get("tools").unwrap();
|
let tools = self.config.get("tools").unwrap();
|
||||||
|
if template_box != "NONE" || new_project.distrobox {
|
||||||
let db = DistroBox {
|
let db = DistroBox {
|
||||||
name: format!(
|
name: format!(
|
||||||
"{}-{}-{}",
|
"{}-{}-{}",
|
||||||
@@ -179,6 +180,9 @@ impl AppState {
|
|||||||
template: template_box.clone(),
|
template: template_box.clone(),
|
||||||
};
|
};
|
||||||
new_project.db = Some(db);
|
new_project.db = Some(db);
|
||||||
|
} else {
|
||||||
|
new_project.db = None;
|
||||||
|
}
|
||||||
self.projects.push(new_project);
|
self.projects.push(new_project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -581,11 +585,24 @@ impl AppState {
|
|||||||
let project = self.projects[self.selected_project].clone();
|
let project = self.projects[self.selected_project].clone();
|
||||||
if let Some(cmd) = self.config.get("term_cmd") {
|
if let Some(cmd) = self.config.get("term_cmd") {
|
||||||
if let Some(db) = project.db {
|
if let Some(db) = project.db {
|
||||||
db.launch_terminal(cmd.to_string());
|
let _ = self
|
||||||
|
.main_tx
|
||||||
|
.send(ToolMessage::Output((rid, format!("launcing distrobox..."))));
|
||||||
|
db.launch_terminal(
|
||||||
|
cmd.to_string(),
|
||||||
|
self.projects[self.selected_project].files.clone(),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if let Some((prog, _)) = cmd.split_once(" ") {
|
if let Some((prog, _)) = cmd.split_once(" ") {
|
||||||
let mut launch_cmd = Command::new(prog);
|
let mut launch_cmd = Command::new(prog);
|
||||||
match launch_cmd.spawn() {
|
launch_cmd.current_dir(&project.files);
|
||||||
|
if let Some(dir) = launch_cmd.get_current_dir() {
|
||||||
|
let _ = self.main_tx.send(ToolMessage::Output((
|
||||||
|
rid,
|
||||||
|
format!("launcing terminal in {}", dir.display()),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
match launch_cmd.current_dir(&project.files).spawn() {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let _ = self.main_tx.send(ToolMessage::Output((
|
let _ = self.main_tx.send(ToolMessage::Output((
|
||||||
@@ -2025,6 +2042,7 @@ impl AppState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut db = None;
|
let mut db = None;
|
||||||
|
let mut distrobx = false;
|
||||||
if template_box != &"NONE".to_string() {
|
if template_box != &"NONE".to_string() {
|
||||||
db = Some(DistroBox {
|
db = Some(DistroBox {
|
||||||
name: format!("{}-{}-{}", template_box, org, name),
|
name: format!("{}-{}-{}", template_box, org, name),
|
||||||
@@ -2036,6 +2054,7 @@ impl AppState {
|
|||||||
created: false,
|
created: false,
|
||||||
template: template_box.to_string(),
|
template: template_box.to_string(),
|
||||||
});
|
});
|
||||||
|
distrobx = true;
|
||||||
};
|
};
|
||||||
let mut new_project = Project {
|
let mut new_project = Project {
|
||||||
org_name: org,
|
org_name: org,
|
||||||
@@ -2046,6 +2065,7 @@ impl AppState {
|
|||||||
config_folder: project_config_file,
|
config_folder: project_config_file,
|
||||||
current: false,
|
current: false,
|
||||||
db: db,
|
db: db,
|
||||||
|
distrobox: distrobx,
|
||||||
scope: Vec::new(),
|
scope: Vec::new(),
|
||||||
exclusions: Vec::new(),
|
exclusions: Vec::new(),
|
||||||
};
|
};
|
||||||
@@ -2084,8 +2104,24 @@ impl AppState {
|
|||||||
rid,
|
rid,
|
||||||
String::from("[success] folders copied!"),
|
String::from("[success] folders copied!"),
|
||||||
)))?;
|
)))?;
|
||||||
|
let mut old_files = new_project.files.clone();
|
||||||
|
let mut old_notes = new_project.notes.clone();
|
||||||
|
old_files.pop();
|
||||||
|
old_notes.pop();
|
||||||
remove_dir_all(&new_project.files)?;
|
remove_dir_all(&new_project.files)?;
|
||||||
remove_dir_all(&new_project.notes)?;
|
remove_dir_all(&new_project.notes)?;
|
||||||
|
if let Err(_) = remove_dir(old_files) {
|
||||||
|
self.main_tx.send(ToolMessage::Output((
|
||||||
|
rid,
|
||||||
|
String::from("organization files folder is not empty and will not be deleted."),
|
||||||
|
)))?;
|
||||||
|
}
|
||||||
|
if let Err(_) = remove_dir(old_notes) {
|
||||||
|
self.main_tx.send(ToolMessage::Output((
|
||||||
|
rid,
|
||||||
|
String::from("organization notes folder is not empty and will not be deleted."),
|
||||||
|
)))?;
|
||||||
|
}
|
||||||
new_files_path.push(&new_project.name);
|
new_files_path.push(&new_project.name);
|
||||||
new_notes_path.push(&new_project.name);
|
new_notes_path.push(&new_project.name);
|
||||||
new_project.files(new_files_path.clone());
|
new_project.files(new_files_path.clone());
|
||||||
@@ -2097,9 +2133,13 @@ impl AppState {
|
|||||||
)))?;
|
)))?;
|
||||||
self.main_tx.send(ToolMessage::Output((
|
self.main_tx.send(ToolMessage::Output((
|
||||||
rid,
|
rid,
|
||||||
String::from("creating distrobox..."),
|
String::from("checking if distrobox should be used..."),
|
||||||
)))?;
|
)))?;
|
||||||
if let Some(mut db) = new_project.db {
|
if let Some(mut db) = new_project.db {
|
||||||
|
self.main_tx.send(ToolMessage::Output((
|
||||||
|
rid,
|
||||||
|
String::from("creating distrobox..."),
|
||||||
|
)))?;
|
||||||
db.volumes = vec![
|
db.volumes = vec![
|
||||||
new_files_path.display().to_string(),
|
new_files_path.display().to_string(),
|
||||||
new_notes_path.display().to_string(),
|
new_notes_path.display().to_string(),
|
||||||
@@ -2111,6 +2151,11 @@ impl AppState {
|
|||||||
rid,
|
rid,
|
||||||
String::from("distrobox sent to rebuild function..."),
|
String::from("distrobox sent to rebuild function..."),
|
||||||
)))?;
|
)))?;
|
||||||
|
} else {
|
||||||
|
self.main_tx.send(ToolMessage::Output((
|
||||||
|
rid,
|
||||||
|
String::from("Distrobox was not configured at the creation of this project, so no distrobox will be created."),
|
||||||
|
)))?;
|
||||||
}
|
}
|
||||||
new_project.save_config()?;
|
new_project.save_config()?;
|
||||||
self.projects[self.selected_project] = new_project;
|
self.projects[self.selected_project] = new_project;
|
||||||
|
|||||||
+13
-3
@@ -22,6 +22,7 @@ pub struct Project {
|
|||||||
pub hosts: Vec<Host>,
|
pub hosts: Vec<Host>,
|
||||||
pub current: bool,
|
pub current: bool,
|
||||||
pub db: Option<DistroBox>,
|
pub db: Option<DistroBox>,
|
||||||
|
pub distrobox: bool,
|
||||||
pub scope: Vec<String>,
|
pub scope: Vec<String>,
|
||||||
pub exclusions: Vec<String>,
|
pub exclusions: Vec<String>,
|
||||||
}
|
}
|
||||||
@@ -37,6 +38,7 @@ impl Project {
|
|||||||
hosts: Vec::new(),
|
hosts: Vec::new(),
|
||||||
current: false,
|
current: false,
|
||||||
db: None,
|
db: None,
|
||||||
|
distrobox: false,
|
||||||
scope: Vec::new(),
|
scope: Vec::new(),
|
||||||
exclusions: Vec::new(),
|
exclusions: Vec::new(),
|
||||||
}
|
}
|
||||||
@@ -117,6 +119,13 @@ impl Project {
|
|||||||
self.exclusions.push(ip.to_string());
|
self.exclusions.push(ip.to_string());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
"db" => {
|
||||||
|
if parts[1].contains("false") {
|
||||||
|
self.distrobox = false;
|
||||||
|
} else {
|
||||||
|
self.distrobox = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,13 +245,14 @@ impl Project {
|
|||||||
}
|
}
|
||||||
let mut file = File::create(&self.config_folder)?;
|
let mut file = File::create(&self.config_folder)?;
|
||||||
let mut out_string = format!(
|
let mut out_string = format!(
|
||||||
"org_name: {}\nname: {}\nnotes: {}\nfiles: {}\nscope: {}\nexclusions: {}\n",
|
"org_name: {}\nname: {}\nnotes: {}\nfiles: {}\nscope: {}\nexclusions: {}\ndb: {}\n",
|
||||||
self.org_name,
|
self.org_name,
|
||||||
self.name,
|
self.name,
|
||||||
self.notes.display(),
|
self.notes.display(),
|
||||||
self.files.display(),
|
self.files.display(),
|
||||||
self.scope.join(","),
|
self.scope.join(","),
|
||||||
self.exclusions.join(","),
|
self.exclusions.join(","),
|
||||||
|
self.distrobox
|
||||||
);
|
);
|
||||||
if self.current {
|
if self.current {
|
||||||
out_string.push_str("stage: current");
|
out_string.push_str("stage: current");
|
||||||
@@ -458,7 +468,7 @@ impl DistroBox {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn launch_terminal(&self, cmd: String) {
|
pub fn launch_terminal(&self, cmd: String, dir: PathBuf) {
|
||||||
if let Some((terminal_cmd, args)) = cmd.split_once(" ") {
|
if let Some((terminal_cmd, args)) = cmd.split_once(" ") {
|
||||||
let mut term_cmd = Command::new(terminal_cmd);
|
let mut term_cmd = Command::new(terminal_cmd);
|
||||||
args.split(" ").into_iter().for_each(|arg| {
|
args.split(" ").into_iter().for_each(|arg| {
|
||||||
@@ -474,7 +484,7 @@ impl DistroBox {
|
|||||||
term_cmd.arg(arg);
|
term_cmd.arg(arg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let _ = term_cmd.spawn();
|
let _ = term_cmd.current_dir(dir).spawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user