Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jldeen committed Dec 15, 2021
1 parent 7a20dfc commit 608373a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
14 changes: 3 additions & 11 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ pub fn get_app_cli<'a, 'b>(version: &'b str) -> App<'a, 'b> {
.help("Elgato Keylight IP address")
.index(4)
.required(true)
.aliases(&[
"elgato_ip",
"elgato-ip",
"elgato ip",
])
.aliases(&["elgato_ip", "elgato-ip", "elgato ip"])
.env("ELGATO_IP")
.takes_value(true),
)
Expand All @@ -27,11 +23,7 @@ pub fn get_app_cli<'a, 'b>(version: &'b str) -> App<'a, 'b> {
.help("Number of Elgato Keylights in use")
.required(true)
.index(5)
.aliases(&[
"number_of_lights",
"number-of-lights",
"number of lights",
])
.aliases(&["number_of_lights", "number-of-lights", "number of lights"])
.env("NUMBER_OF_LIGHTS")
.takes_value(true),
)
Expand All @@ -56,4 +48,4 @@ pub fn get_app_cli<'a, 'b>(version: &'b str) -> App<'a, 'b> {
.index(3)
.default_value("medium"),
)
}
}
14 changes: 5 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
mod cli;

use cli::get_app_cli;
use reqwest::Client;
use serde_json::json;
use std::env;
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
env!("CARGO_PKG_VERSION"),
option_env!("BUILD_BUILDID").unwrap_or("0")
);

let matches = get_app_cli(&version).get_matches();
let elgato_ip = matches.value_of("ELGATO_IP").unwrap();
let numberoflights = matches.value_of("NUMBER_OF_LIGHTS").unwrap();
Expand All @@ -33,24 +33,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
]
});
let url = format!("http://{}:{}", elgato_ip, "9123/elgato/lights");

println!("State: {}", url);

let client = reqwest::Client::new();

let response = client
.put(url)
.json(&body)
.send()
.await?;
let response = client.put(url).json(&body).send().await?;

let status = response.status();
let response_body = response.text().await?;
let response_json: serde_json::Value = serde_json::from_str(&response_body)?;

println!("Response status: {}", status);
println!("Response text: {}", response_body);
println!("Response json: {:?}", response_json);
println!("Response json: {:?}", response_json);

Ok(())
}

0 comments on commit 608373a

Please sign in to comment.