Skip to content

Commit

Permalink
feat: added os option to mise.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Nov 16, 2024
1 parent 0ea3156 commit 21b686b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ shellcheck = "0.10"
shfmt = "3"
jq = "latest"
cargo-binstall = "latest"
"cargo:cargo-edit" = "latest"
"cargo:cargo-edit" = {version = "latest", os=["linux", "macos"]}
"cargo:cargo-show" = "latest"
"cargo:cargo-insta" = "latest"
"cargo:git-cliff" = "latest"
Expand Down
8 changes: 6 additions & 2 deletions src/config/config_file/mise_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub struct MiseTomlToolList(Vec<MiseTomlTool>);
#[derive(Debug, Clone)]
pub struct MiseTomlTool {
pub tt: ToolVersionType,
pub os: Option<String>,
pub options: Option<ToolVersionOptions>,
}

Expand Down Expand Up @@ -777,18 +778,21 @@ impl<'de> de::Deserialize<'de> for MiseTomlToolList {
where
M: de::MapAccess<'de>,
{
let mut options: BTreeMap<String, String> =
let mut options: BTreeMap<String, Value> =
de::Deserialize::deserialize(de::value::MapAccessDeserializer::new(map))?;
let os = options.remove("os");
let tt: ToolVersionType = options
.remove("version")
.or_else(|| options.remove("path").map(|p| format!("path:{p}")))
.map(|v| v.as_str().unwrap().to_string())
.or_else(|| options.remove("path").map(|p| format!("path:{}", p.as_str().unwrap().to_string())))
.or_else(|| options.remove("prefix").map(|p| format!("prefix:{p}")))
.or_else(|| options.remove("ref").map(|p| format!("ref:{p}")))
.ok_or_else(|| de::Error::custom("missing version"))?
.parse()
.map_err(de::Error::custom)?;
Ok(MiseTomlToolList(vec![MiseTomlTool {
tt,
os,
options: Some(options),
}]))
}
Expand Down

0 comments on commit 21b686b

Please sign in to comment.