-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from auyer/feature/better-parametrization
Main routine refactor + better parametrization
- Loading branch information
Showing
10 changed files
with
400 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
repos: | ||
- repo: https://github.com/crate-ci/typos | ||
rev: v1.14.5 | ||
hooks: | ||
- id: typos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod constants; | ||
pub mod file; | ||
pub mod github; | ||
pub mod parameters; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
use super::constants::*; | ||
use std::{fmt, str::FromStr}; | ||
// VariantParameters stores the parameters for a variant of Proton | ||
pub struct VariantParameters { | ||
/// this is a link back to the enum variant | ||
variant_ref: Variant, | ||
/// URL of the repository server (GitHub compatible URL only at the moment) | ||
pub repository_url: String, | ||
/// GitHub account for the variant | ||
pub repository_account: String, | ||
/// name of the repository | ||
pub repository_name: String, | ||
} | ||
|
||
impl VariantParameters { | ||
/// new_custom is a generator for custom VariantParameters | ||
pub fn new_custom( | ||
variant: Variant, | ||
repository_url: String, | ||
repository_account: String, | ||
repository_name: String, | ||
) -> VariantParameters { | ||
VariantParameters { | ||
variant_ref: variant, | ||
repository_url, | ||
repository_account, | ||
repository_name, | ||
} | ||
} | ||
|
||
/// | ||
pub fn variant_type(&self) -> &Variant { | ||
return &self.variant_ref; | ||
} | ||
} | ||
|
||
/// Variant is an enum with all supported "Proton" versions | ||
pub enum Variant { | ||
GEProton, | ||
WineGE, | ||
} | ||
|
||
impl fmt::Display for Variant { | ||
/// returns a string representation of this variant | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
Variant::GEProton => write!(f, "GEProton"), | ||
Variant::WineGE => write!(f, "WineGE"), | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for Variant { | ||
type Err = (); | ||
fn from_str(input: &str) -> Result<Variant, Self::Err> { | ||
match input { | ||
"GEProton" => Ok(Variant::GEProton), | ||
"WineGE" => Ok(Variant::WineGE), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
|
||
impl Variant { | ||
/// returns the application target for the Variant. Steam and Lutris are the current options | ||
pub fn intended_application(&self) -> &str { | ||
match self { | ||
Variant::GEProton => "Steam", | ||
Variant::WineGE => "Lutris", | ||
} | ||
} | ||
|
||
/// returns the default parameters for this Variant. | ||
pub fn parameters(&self) -> VariantParameters { | ||
match self { | ||
Variant::GEProton => VariantParameters { | ||
variant_ref: Variant::GEProton, | ||
repository_url: GITHUB_URL.to_owned(), | ||
repository_name: GEPROTON_GITHUB_REPO.to_owned(), | ||
repository_account: GE_GITHUB_ACCOUNT.to_owned(), | ||
}, | ||
Variant::WineGE => VariantParameters { | ||
variant_ref: Variant::WineGE, | ||
repository_url: GITHUB_URL.to_owned(), | ||
repository_name: WINEGE_GITHUB_REPO.to_owned(), | ||
repository_account: GE_GITHUB_ACCOUNT.to_owned(), | ||
}, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.