cli/commands: use constants for repeated platform names
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I33c2cb59c73791a16f322e8544161a496a6a6964
This commit is contained in:
parent
34976a66d2
commit
f70e3b8690
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()
|
||||
-> Result<HashMap<String, Box<dyn crate::platform::PlatformClient>>> {
|
||||
const MODRINTH: &str = "modrinth";
|
||||
const CURSEFORGE: &str = "curseforge";
|
||||
|
||||
let mut platforms = HashMap::new();
|
||||
|
||||
if let Ok(platform) = create_platform("modrinth", None) {
|
||||
platforms.insert("modrinth".to_string(), platform);
|
||||
if let Ok(platform) = create_platform(MODRINTH, None) {
|
||||
platforms.insert(MODRINTH.to_owned(), 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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue