diff --git a/README.md b/README.md index be1dab7..138dc7d 100644 --- a/README.md +++ b/README.md @@ -33,15 +33,15 @@ cargo run -- ## Usage -``` +```text Usage: servicepoint-cli [OPTIONS] Commands: - reset-everything Reset both pixels and brightness [aliases: r] - pixels Commands for manipulating pixels [aliases: p] - brightness Commands for manipulating the brightness [aliases: b] - text Commands for sending text to the screen [aliases: t] - help Print this message or the help of the given subcommand(s) + reset Reset both pixels and brightness [aliases: r] + pixels Commands for manipulating pixels [aliases: p] + brightness Commands for manipulating the brightness [aliases: b] + text Commands for sending text to the screen [aliases: t] + help Print this message or the help of the given subcommand(s) Options: -d, --destination ip:port of the servicepoint display [default: 127.0.0.1:2342] @@ -53,7 +53,7 @@ Options: ### Pixels -``` +```text Commands for manipulating pixels Usage: servicepoint-cli pixels @@ -68,7 +68,7 @@ Commands: #### Image -``` +```text Send an image file (e.g. jpeg or png) to the display. Usage: servicepoint-cli pixels image [OPTIONS] @@ -87,7 +87,7 @@ Options: #### Screen -``` +```text Stream the default screen capture source to the display. On Linux Wayland, this pops up a screen or window chooser, but it also may directly start streaming your main screen. Usage: servicepoint-cli pixels screen [OPTIONS] @@ -104,7 +104,7 @@ Options: ### Brightness -``` +```text Commands for manipulating the brightness Usage: servicepoint-cli brightness @@ -117,18 +117,18 @@ Commands: ### Text -``` +```text Commands for sending text to the screen Usage: servicepoint-cli text Commands: - stdin Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin` + stdin Pipe text to the display, example: `journalctl | servicepoint-cli text stdin` ``` #### Stdin -``` +```text Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin` Usage: servicepoint-cli stream stdin [OPTIONS] @@ -137,6 +137,16 @@ Options: -s, --slow Wait for a short amount of time before sending the next line ``` +### Reset + +```text +Reset both pixels and brightness + +Usage: servicepoint-cli reset [OPTIONS] + +Options: +-f, --force hard reset screen +``` ## Contributing diff --git a/src/cli.rs b/src/cli.rs index bfec0ac..543ba36 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -29,7 +29,10 @@ pub struct Cli { #[derive(clap::Parser, std::fmt::Debug)] pub enum Mode { #[command(visible_alias = "r", about = "Reset both pixels and brightness")] - ResetEverything, + Reset { + #[arg(short, long, help = "hard reset screen")] + force: bool, + }, #[command(visible_alias = "p")] Pixels { #[clap(subcommand)] @@ -114,7 +117,7 @@ pub enum TransportType { #[clap(about = "Commands for sending text to the screen")] pub enum TextCommand { #[command( - about = "Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`" + about = "Pipe text to the display, example: `journalctl | servicepoint-cli text stdin`" )] Stdin { #[arg( diff --git a/src/main.rs b/src/main.rs index d72bbfd..a485526 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use crate::{ }; use clap::Parser; use log::debug; -use servicepoint::{Brightness, UdpSocketExt}; +use servicepoint::{Brightness, HardResetCommand, UdpSocketExt}; mod brightness; mod cli; @@ -32,9 +32,13 @@ fn main() { pub fn execute_mode(mode: Mode, connection: Transport) { match mode { - Mode::ResetEverything => { - brightness_set(&connection, Brightness::MAX); - pixels_off(&connection); + Mode::Reset { force } => { + if force { + connection.send_command(HardResetCommand).unwrap() + } else { + brightness_set(&connection, Brightness::MAX); + pixels_off(&connection); + } } Mode::Pixels { pixel_command } => pixels(&connection, pixel_command), Mode::Brightness { brightness_command } => brightness(&connection, brightness_command),