Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
feat(cli): add status subcommand
Browse files Browse the repository at this point in the history
Closes #22
  • Loading branch information
saidsay-so committed Nov 7, 2021
1 parent 4f4b312 commit 13981d1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
10 changes: 9 additions & 1 deletion cli/extra/fancy.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fancy - Fancy CLI

# SYNOPSIS

`fancy get [speeds | temps | config]`
`fancy get [speeds | temps | config | auto | status]`

`fancy set [-f FAN_SPEED [FAN_SPEEDS ...] | -a] [-c CONFIGURATION]`

Expand Down Expand Up @@ -50,6 +50,14 @@ a set of software which allows to control laptop fans.

: Get current configuration

`fancy get auto`

: Get automatic speed management state

`fancy get status`

: Get summary

#### LIST

List all available configurations
Expand Down
3 changes: 2 additions & 1 deletion cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ pub fn get_app() -> App<'static, 'static> {
.subcommand(SubCommand::with_name("speeds").about("Get the fans speeds"))
.subcommand(SubCommand::with_name("temps").about("Get the temperatures"))
.subcommand(SubCommand::with_name("config").about("Get the current config"))
.subcommand(SubCommand::with_name("auto").about("Get auto-handle state")),
.subcommand(SubCommand::with_name("auto").about("Get auto-handle state"))
.subcommand(SubCommand::with_name("status").about("Get summary")),
)
.subcommand(
SubCommand::with_name("list")
Expand Down
25 changes: 20 additions & 5 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,34 @@ fn main() -> Result<(), anyhow::Error> {
let matches = get_app().get_matches();

if let Some(matches) = matches.subcommand_matches("get") {
if matches.is_present("speeds") {
if matches.is_present("speeds") || matches.is_present("status") {
if matches.is_present("status") {
println!("Fans speeds");
}
let fans_speeds = proxy.fans_speeds()?;
let names = proxy.fans_names()?;
for (name, speed) in names.iter().zip(fans_speeds) {
println!("{}: {:.1}%", name, speed);
}
} else if matches.is_present("config") {
}
if matches.is_present("config") || matches.is_present("status") {
if matches.is_present("status") {
print!("\nConfig: ");
}
let config = proxy.config()?;
println!("{}", config);
} else if matches.is_present("auto") {
}
if matches.is_present("auto") || matches.is_present("status") {
if matches.is_present("status") {
print!("\nAuto-select thresholds: ");
}
let auto = proxy.auto()?;
println!("Auto-select thresholds: {}", auto);
} else if matches.is_present("temps") {
println!("{}", auto);
}
if matches.is_present("temps") || matches.is_present("status") {
if matches.is_present("status") {
println!("\nTemperatures");
}
let temps = proxy.temperatures()?;
for (sensor, temp) in temps {
println!("{}: {:.1}°C", sensor, temp);
Expand Down

0 comments on commit 13981d1

Please sign in to comment.