cli/commands: use constants for repeated platform names
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I33c2cb59c73791a16f322e8544161a496a6a6964
This commit is contained in:
parent
a1357b2501
commit
bc74c24dd5
1 changed files with 7 additions and 4 deletions
|
|
@ -13,15 +13,18 @@ fn get_loaders(lockfile: &LockFile) -> Vec<String> {
|
||||||
|
|
||||||
pub fn create_all_platforms()
|
pub fn create_all_platforms()
|
||||||
-> Result<HashMap<String, Box<dyn crate::platform::PlatformClient>>> {
|
-> Result<HashMap<String, Box<dyn crate::platform::PlatformClient>>> {
|
||||||
|
const MODRINTH: &str = "modrinth";
|
||||||
|
const CURSEFORGE: &str = "curseforge";
|
||||||
|
|
||||||
let mut platforms = HashMap::new();
|
let mut platforms = HashMap::new();
|
||||||
|
|
||||||
if let Ok(platform) = create_platform("modrinth", None) {
|
if let Ok(platform) = create_platform(MODRINTH, None) {
|
||||||
platforms.insert("modrinth".to_string(), platform);
|
platforms.insert(MODRINTH.to_owned(), platform);
|
||||||
}
|
}
|
||||||
if let Ok(platform) =
|
if let Ok(platform) =
|
||||||
create_platform("curseforge", std::env::var("CURSEFORGE_API_KEY").ok())
|
create_platform(CURSEFORGE, std::env::var("CURSEFORGE_API_KEY").ok())
|
||||||
{
|
{
|
||||||
platforms.insert("curseforge".to_string(), platform);
|
platforms.insert(CURSEFORGE.to_owned(), platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(platforms)
|
Ok(platforms)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue