restructure cli
This commit is contained in:
parent
0ac6b77ed0
commit
11d9ac0bcb
117
README.md
117
README.md
|
@ -40,7 +40,7 @@ Commands:
|
||||||
reset-everything Reset both pixels and brightness [aliases: r]
|
reset-everything Reset both pixels and brightness [aliases: r]
|
||||||
pixels Commands for manipulating pixels [aliases: p]
|
pixels Commands for manipulating pixels [aliases: p]
|
||||||
brightness Commands for manipulating the brightness [aliases: b]
|
brightness Commands for manipulating the brightness [aliases: b]
|
||||||
stream Continuously send data to the display [aliases: s]
|
text Commands for sending text to the screen [aliases: t]
|
||||||
help Print this message or the help of the given subcommand(s)
|
help Print this message or the help of the given subcommand(s)
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
@ -51,59 +51,6 @@ Options:
|
||||||
-V, --version Print version
|
-V, --version Print version
|
||||||
```
|
```
|
||||||
|
|
||||||
### Stream
|
|
||||||
|
|
||||||
```
|
|
||||||
Continuously send data to the display
|
|
||||||
|
|
||||||
Usage: servicepoint-cli stream <COMMAND>
|
|
||||||
|
|
||||||
Commands:
|
|
||||||
stdin Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`
|
|
||||||
screen Stream the default 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.
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Screen
|
|
||||||
|
|
||||||
```
|
|
||||||
Stream the default 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 stream screen [OPTIONS]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-p, --pointer Show mouse pointer in video feed
|
|
||||||
--no-hist Disable histogram correction
|
|
||||||
--no-blur Disable blur
|
|
||||||
--no-sharp Disable sharpening
|
|
||||||
--no-dither Disable dithering. Brightness will be adjusted so that around half of the pixels are on.
|
|
||||||
--no-spacers Do not remove the spacers from the image.
|
|
||||||
--no-aspect Do not keep aspect ratio when resizing.
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Stdin
|
|
||||||
|
|
||||||
```
|
|
||||||
Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`
|
|
||||||
|
|
||||||
Usage: servicepoint-cli stream stdin [OPTIONS]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-s, --slow Wait for a short amount of time before sending the next line
|
|
||||||
```
|
|
||||||
|
|
||||||
### Brightness
|
|
||||||
|
|
||||||
```
|
|
||||||
Commands for manipulating the brightness
|
|
||||||
|
|
||||||
Usage: servicepoint-cli brightness <COMMAND>
|
|
||||||
|
|
||||||
Commands:
|
|
||||||
max Reset brightness to the default (max) level [aliases: r, reset]
|
|
||||||
set Set one brightness for the whole screen [aliases: s]
|
|
||||||
min Set brightness to lowest possible level.
|
|
||||||
```
|
|
||||||
|
|
||||||
### Pixels
|
### Pixels
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -112,10 +59,11 @@ Commands for manipulating pixels
|
||||||
Usage: servicepoint-cli pixels <COMMAND>
|
Usage: servicepoint-cli pixels <COMMAND>
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
off Reset all pixels to the default (off) state [aliases: r, reset, clear]
|
off Reset all pixels to the default (off) state [aliases: r, reset, clear]
|
||||||
flip Invert the state of all pixels [aliases: f]
|
flip Invert the state of all pixels [aliases: f]
|
||||||
on Set all pixels to the on state
|
on Set all pixels to the on state
|
||||||
image Send an image file (e.g. jpeg or png) to the display. [aliases: i]
|
image Send an image file (e.g. jpeg or png) to the display. [aliases: i]
|
||||||
|
screen 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. [aliases: s]
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Image
|
#### Image
|
||||||
|
@ -137,6 +85,59 @@ Options:
|
||||||
--no-aspect Do not keep aspect ratio when resizing.
|
--no-aspect Do not keep aspect ratio when resizing.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Screen
|
||||||
|
|
||||||
|
```
|
||||||
|
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]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-p, --pointer Show mouse pointer in video feed
|
||||||
|
--no-hist Disable histogram correction
|
||||||
|
--no-blur Disable blur
|
||||||
|
--no-sharp Disable sharpening
|
||||||
|
--no-dither Disable dithering. Brightness will be adjusted so that around half of the pixels are on.
|
||||||
|
--no-spacers Do not remove the spacers from the image.
|
||||||
|
--no-aspect Do not keep aspect ratio when resizing.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Brightness
|
||||||
|
|
||||||
|
```
|
||||||
|
Commands for manipulating the brightness
|
||||||
|
|
||||||
|
Usage: servicepoint-cli brightness <COMMAND>
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
max Reset brightness to the default (max) level [aliases: r, reset]
|
||||||
|
set Set one brightness for the whole screen [aliases: s]
|
||||||
|
min Set brightness to lowest possible level.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Text
|
||||||
|
|
||||||
|
```
|
||||||
|
Commands for sending text to the screen
|
||||||
|
|
||||||
|
Usage: servicepoint-cli text <COMMAND>
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
stdin Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Stdin
|
||||||
|
|
||||||
|
```
|
||||||
|
Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`
|
||||||
|
|
||||||
|
Usage: servicepoint-cli stream stdin [OPTIONS]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-s, --slow Wait for a short amount of time before sending the next line
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
If you have ideas on how to improve the code, add features or improve documentation feel free to open a pull request.
|
If you have ideas on how to improve the code, add features or improve documentation feel free to open a pull request.
|
||||||
|
|
31
src/cli.rs
31
src/cli.rs
|
@ -40,10 +40,10 @@ pub enum Mode {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
brightness_command: BrightnessCommand,
|
brightness_command: BrightnessCommand,
|
||||||
},
|
},
|
||||||
#[command(visible_alias = "s")]
|
#[command(visible_alias = "t")]
|
||||||
Stream {
|
Text {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
stream_command: StreamCommand,
|
text_command: TextCommand,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +71,18 @@ pub enum PixelCommand {
|
||||||
#[command(flatten)]
|
#[command(flatten)]
|
||||||
image_processing_options: ImageProcessingOptions,
|
image_processing_options: ImageProcessingOptions,
|
||||||
},
|
},
|
||||||
|
#[command(
|
||||||
|
visible_alias = "s",
|
||||||
|
about = "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."
|
||||||
|
)]
|
||||||
|
Screen {
|
||||||
|
#[command(flatten)]
|
||||||
|
stream_options: StreamScreenOptions,
|
||||||
|
#[command(flatten)]
|
||||||
|
image_processing: ImageProcessingOptions,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Parser, std::fmt::Debug)]
|
#[derive(clap::Parser, std::fmt::Debug)]
|
||||||
|
@ -99,8 +111,8 @@ pub enum Protocol {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Parser, std::fmt::Debug)]
|
#[derive(clap::Parser, std::fmt::Debug)]
|
||||||
#[clap(about = "Continuously send data to the display")]
|
#[clap(about = "Commands for sending text to the screen")]
|
||||||
pub enum StreamCommand {
|
pub enum TextCommand {
|
||||||
#[command(
|
#[command(
|
||||||
about = "Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`"
|
about = "Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`"
|
||||||
)]
|
)]
|
||||||
|
@ -113,15 +125,6 @@ pub enum StreamCommand {
|
||||||
)]
|
)]
|
||||||
slow: bool,
|
slow: bool,
|
||||||
},
|
},
|
||||||
#[command(about = "Stream the default 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.")]
|
|
||||||
Screen {
|
|
||||||
#[command(flatten)]
|
|
||||||
stream_options: StreamScreenOptions,
|
|
||||||
#[command(flatten)]
|
|
||||||
image_processing: ImageProcessingOptions,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Parser, std::fmt::Debug, Clone)]
|
#[derive(clap::Parser, std::fmt::Debug, Clone)]
|
||||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -1,9 +1,8 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
brightness::{brightness, brightness_set},
|
brightness::{brightness, brightness_set},
|
||||||
cli::{Cli, Mode, Protocol, StreamCommand},
|
cli::{Cli, Mode, Protocol},
|
||||||
pixels::{pixels, pixels_off},
|
pixels::{pixels, pixels_off},
|
||||||
stream_stdin::stream_stdin,
|
text::text
|
||||||
stream_window::stream_window,
|
|
||||||
};
|
};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
@ -16,6 +15,7 @@ mod ledwand_dither;
|
||||||
mod pixels;
|
mod pixels;
|
||||||
mod stream_stdin;
|
mod stream_stdin;
|
||||||
mod stream_window;
|
mod stream_window;
|
||||||
|
mod text;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
|
@ -36,13 +36,7 @@ pub fn execute_mode(mode: Mode, connection: Connection) {
|
||||||
}
|
}
|
||||||
Mode::Pixels { pixel_command } => pixels(&connection, pixel_command),
|
Mode::Pixels { pixel_command } => pixels(&connection, pixel_command),
|
||||||
Mode::Brightness { brightness_command } => brightness(&connection, brightness_command),
|
Mode::Brightness { brightness_command } => brightness(&connection, brightness_command),
|
||||||
Mode::Stream { stream_command } => match stream_command {
|
Mode::Text { text_command} => text(&connection, text_command),
|
||||||
StreamCommand::Stdin { slow } => stream_stdin(connection, slow),
|
|
||||||
StreamCommand::Screen {
|
|
||||||
stream_options,
|
|
||||||
image_processing,
|
|
||||||
} => stream_window(&connection, stream_options, image_processing),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
use crate::cli::{ImageProcessingOptions, PixelCommand, SendImageOptions};
|
use crate::{
|
||||||
use crate::image_processing::ImageProcessingPipeline;
|
image_processing::ImageProcessingPipeline,
|
||||||
|
cli::{ImageProcessingOptions, PixelCommand, SendImageOptions},
|
||||||
|
stream_window::stream_window
|
||||||
|
};
|
||||||
use log::info;
|
use log::info;
|
||||||
use servicepoint::{BitVec, Command, CompressionCode, Connection, Origin, PIXEL_COUNT};
|
use servicepoint::{BitVec, Command, CompressionCode, Connection, Origin, PIXEL_COUNT};
|
||||||
|
|
||||||
|
@ -12,6 +15,10 @@ pub(crate) fn pixels(connection: &Connection, pixel_command: PixelCommand) {
|
||||||
image_processing_options: processing_options,
|
image_processing_options: processing_options,
|
||||||
send_image_options: image_options,
|
send_image_options: image_options,
|
||||||
} => pixels_image(connection, image_options, processing_options),
|
} => pixels_image(connection, image_options, processing_options),
|
||||||
|
PixelCommand::Screen {
|
||||||
|
stream_options,
|
||||||
|
image_processing,
|
||||||
|
} => stream_window(connection, stream_options, image_processing),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use log::warn;
|
||||||
use servicepoint::*;
|
use servicepoint::*;
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
|
|
||||||
pub(crate) fn stream_stdin(connection: Connection, slow: bool) {
|
pub(crate) fn stream_stdin(connection: &Connection, slow: bool) {
|
||||||
warn!("This mode will break when using multi-byte characters and does not support ANSI escape sequences yet.");
|
warn!("This mode will break when using multi-byte characters and does not support ANSI escape sequences yet.");
|
||||||
let mut app = App {
|
let mut app = App {
|
||||||
connection,
|
connection,
|
||||||
|
@ -13,14 +13,14 @@ pub(crate) fn stream_stdin(connection: Connection, slow: bool) {
|
||||||
app.run()
|
app.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
struct App {
|
struct App<'t> {
|
||||||
connection: Connection,
|
connection: &'t Connection,
|
||||||
mirror: CharGrid,
|
mirror: CharGrid,
|
||||||
y: usize,
|
y: usize,
|
||||||
slow: bool,
|
slow: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App<'_> {
|
||||||
fn run(&mut self) {
|
fn run(&mut self) {
|
||||||
self.connection
|
self.connection
|
||||||
.send(Command::Clear)
|
.send(Command::Clear)
|
||||||
|
|
7
src/text.rs
Normal file
7
src/text.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
use servicepoint::Connection;
|
||||||
|
use crate::cli::TextCommand;
|
||||||
|
use crate::stream_stdin::stream_stdin;
|
||||||
|
|
||||||
|
pub fn text(connection: &Connection, command: TextCommand) {
|
||||||
|
match command { TextCommand::Stdin { slow } => stream_stdin(connection, slow), }
|
||||||
|
}
|
Loading…
Reference in a new issue