From 6af2cc9cac662dcb1ec7cd3929a1a6be8f799ae3 Mon Sep 17 00:00:00 2001 From: Harlley Date: Fri, 21 Jul 2023 10:32:34 -0300 Subject: [PATCH] feat: add option of dinamicaly users --- .github/workflows/main.yml | 2 +- src/main.rs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8ea19db..a66f3a4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: - name: Run tests run: cargo test --verbose - name: Run program - run: cargo run + run: cargo run -- "Harlley Davidson" env: RIOT_API_KEY: ${{ secrets.RIOT_API_KEY }} diff --git a/src/main.rs b/src/main.rs index eb6be85..afcf2b9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,16 +5,10 @@ use reqwest::Error; struct Summoner { #[serde(rename = "id")] id: String, - #[serde(rename = "accountId")] - account_id: String, - #[serde(rename = "puuid")] - puuid: String, #[serde(rename = "name")] name: String, #[serde(rename = "profileIconId")] profile_icon_id: i32, - #[serde(rename = "revisionDate")] - revision_date: i64, #[serde(rename = "summonerLevel")] summoner_level: i32, } @@ -22,7 +16,14 @@ struct Summoner { #[tokio::main] async fn main() -> Result<(), Error> { let api_key = std::env::var("RIOT_API_KEY").expect("RIOT_API_KEY is not set"); - let summoner_name = "Harlley Davidson"; + + println!("Enter a summoner name: "); + + let mut summoner_name = String::new(); + std::io::stdin().read_line(&mut summoner_name) + .expect("Failed to read line"); + + summoner_name = summoner_name.trim().to_string(); let summoner_url = format!( "https://br1.api.riotgames.com/lol/summoner/v4/summoners/by-name/{}?api_key={}", @@ -32,8 +33,7 @@ async fn main() -> Result<(), Error> { let response = reqwest::get(&summoner_url).await?; let summoner: Summoner = response.json().await?; - println!("{:#?}", summoner); + println!("Summoner {} has ID: {} with Profile Icon ID: {} and Summoner Level: {}", summoner.name, summoner.id, summoner.profile_icon_id, summoner.summoner_level); Ok(()) } -