1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use std::path::PathBuf;
use busylib::{AppName, Brightness, Color, Priority, Text};
use clap::Subcommand;
use crate::cli::Context;
use crate::error::Result;
use crate::values::{AlignArg, FontArg, ScreenArg};
#[derive(Debug, Subcommand)]
pub enum DisplayCommand {
/// Draw a single line of text
Text {
/// Printable ASCII text
#[arg(value_name = "TEXT")]
text: Text,
/// Application name
#[arg(long, short = 'a', value_name = "NAME")]
app: AppName,
/// Font to draw the text in
#[arg(long, value_enum, default_value_t = FontArg::Normal)]
font: FontArg,
/// Anchor point of the text
#[arg(long, value_enum)]
align: Option<AlignArg>,
/// Text color in #RRGGBBAA format
#[arg(long, value_name = "COLOR")]
color: Option<Color>,
/// X coordinate of the anchor point
#[arg(long, allow_negative_numbers = true, default_value_t = 0)]
x: i16,
/// Y coordinate of the anchor point
#[arg(long, allow_negative_numbers = true, default_value_t = 0)]
y: i16,
/// Screen to draw on
#[arg(long, value_enum, default_value_t = ScreenArg::Front)]
screen: ScreenArg,
/// Seconds until the text is hidden
#[arg(long, value_name = "SECONDS")]
timeout: Option<u32>,
/// Draw priority between 1 and 100
#[arg(long, value_name = "PRIORITY")]
priority: Option<Priority>,
/// Blink the status LED in this color
#[arg(long, value_name = "COLOR")]
led: Option<Color>,
},
/// Draw elements from a JSON payload
Draw {
/// JSON draw request, or - for stdin
#[arg(value_name = "FILE")]
file: PathBuf,
},
/// Clear drawn elements
Clear {
/// Only clear the elements of this application
#[arg(long, short = 'a', value_name = "NAME")]
app: Option<AppName>,
},
/// Show the display brightness
Brightness,
/// Set the display brightness
SetBrightness {
/// Percentage between 0 and 100, or auto
#[arg(value_name = "VALUE")]
value: Brightness,
},
/// Capture a single frame of a screen
Frame {
/// Screen to capture
#[arg(value_enum, default_value_t = ScreenArg::Front)]
screen: ScreenArg,
/// Write the bitmap here instead of stdout
#[arg(long, short = 'O', value_name = "FILE")]
output: Option<PathBuf>,
},
}
impl DisplayCommand {
pub async fn run(self, _context: &Context) -> Result<()> {
todo!()
}
}