feat: support setting env vars directly as name=value

This commit is contained in:
Gabriele Musco 2024-03-06 20:45:42 +01:00
parent 03de81d2fb
commit 733c16978e
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
3 changed files with 21 additions and 12 deletions

14
Cargo.lock generated
View file

@ -623,11 +623,11 @@ dependencies = [
[[package]]
name = "git2"
version = "0.17.2"
version = "0.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b989d6a7ca95a362cf2cfc5ad688b3a467be1f87e480b8dad07fee8c79b0044"
checksum = "1b3ba52851e73b46a4c3df1d89343741112003f0f6f13beb0dfac9e457c3fdcd"
dependencies = [
"bitflags 1.3.2",
"bitflags 2.4.0",
"libc",
"libgit2-sys",
"log",
@ -1048,15 +1048,15 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.148"
version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "libgit2-sys"
version = "0.15.2+1.6.4"
version = "0.16.2+1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a80df2e11fb4a61f4ba2ab42dbe7f74468da143f1a75c74e11dee7c813f694fa"
checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8"
dependencies = [
"cc",
"libc",

View file

@ -10,7 +10,7 @@ anyhow = "1.0.75"
gettext-rs = { version = "0.7.0", features = [
"gettext-system"
] }
git2 = "0.17.2"
git2 = "0.18.2"
gtk4 = { version = "0.7.2", features = [
"v4_10",
] }

View file

@ -404,13 +404,22 @@ impl SimpleComponent for ProfileEditor {
self.xrservice_cmake_flags_rows.guard().remove(p);
}
}
Self::Input::AddEnvVar(name) => {
Self::Input::AddEnvVar(var) => {
let mut prof = self.profile.borrow_mut();
if !prof.environment.contains_key(&name) {
prof.environment.insert(name.clone(), "".to_string());
if !prof.environment.contains_key(&var) {
let (name, value) = if var.contains('=') {
let mut sp = var.split('=');
(
sp.next().unwrap().to_string(),
sp.next().unwrap().to_string(),
)
} else {
(var, "".to_string())
};
prof.environment.insert(name.clone(), value.clone());
self.env_rows.guard().push_back(EnvVarModelInit {
name,
value: "".to_string(),
value,
var_type: VarType::EnvVar,
});
}