Skip to content

Commit

Permalink
feat: allow omitting compiler patch version
Browse files Browse the repository at this point in the history
Allows specifying Cairo version like `v2.7` or `2.7` instead of the
full version. Using only the major version like `v2` is not supported
as the Cairo compiler does not follow SemVer, and breaking changes are
introduced between minor versions.
  • Loading branch information
xJonathanLEI committed Sep 22, 2024
1 parent 9f6ea67 commit 22db631
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,18 @@ impl ValueEnum for CompilerVersion {

fn to_possible_value(&self) -> Option<PossibleValue> {
match self {
Self::V2_6_4 => Some(PossibleValue::new("2.6.4").alias("v2.6.4")),
Self::V2_7_1 => Some(PossibleValue::new("2.7.1").alias("v2.7.1")),
Self::V2_6_4 => Some(
PossibleValue::new("2.6.4")
.alias("v2.6.4")
.alias("2.6")
.alias("v2.6"),
),
Self::V2_7_1 => Some(
PossibleValue::new("2.7.1")
.alias("v2.7.1")
.alias("2.7")
.alias("v2.7"),
),
}
}
}
Expand All @@ -158,8 +168,8 @@ impl FromStr for CompilerVersion {

fn from_str(s: &str) -> Result<Self> {
match s {
"2.6.4" | "v2.6.4" => Ok(Self::V2_6_4),
"2.7.1" | "v2.7.1" => Ok(Self::V2_7_1),
"2.6.4" | "v2.6.4" | "2.6" | "v2.6" => Ok(Self::V2_6_4),
"2.7.1" | "v2.7.1" | "2.7" | "v2.7" => Ok(Self::V2_7_1),
_ => Err(anyhow::anyhow!("unknown version: {}", s)),
}
}
Expand Down

0 comments on commit 22db631

Please sign in to comment.