Add usage information to cyberpunk-splash
All checks were successful
Monorepo build / build-flake (push) Successful in 3s
All checks were successful
Monorepo build / build-flake (push) Successful in 3s
This commit is contained in:
parent
41d2854339
commit
126dfa5a1f
@ -421,6 +421,14 @@ impl Splash {
|
||||
}
|
||||
|
||||
|
||||
fn print_usage(message: Option<&str>) {
|
||||
if let Some(message) = message {
|
||||
eprintln!("{}", message);
|
||||
}
|
||||
eprintln!("cyberpunk-splash --title \"My Title\" --countdown 5:00");
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
let app = gtk::Application::builder()
|
||||
.application_id("com.luminescent-dreams.cyberpunk-splash")
|
||||
@ -455,8 +463,16 @@ fn main() {
|
||||
let title = title.clone();
|
||||
let state = state.clone();
|
||||
move |_, options| {
|
||||
println!("connect_handle_local_options");
|
||||
*title.write().unwrap() = options.lookup::<String>("title").unwrap().unwrap();
|
||||
let title_option = match options.lookup::<String>("title") {
|
||||
Ok(Some(title)) => title.clone(),
|
||||
Ok(None) => {
|
||||
print_usage(Some("No title specified"));
|
||||
return 1;
|
||||
}
|
||||
Err(_err) => unreachable!(),
|
||||
};
|
||||
|
||||
*title.write().unwrap() = title_option;
|
||||
let countdown = match options.lookup::<String>("countdown") {
|
||||
Ok(Some(countdown_str)) => {
|
||||
let parts = countdown_str.split(':').collect::<Vec<&str>>();
|
||||
@ -470,10 +486,20 @@ fn main() {
|
||||
let seconds = parts[1].parse::<u64>().unwrap();
|
||||
Duration::from_secs(seconds)
|
||||
}
|
||||
_ => Duration::from_secs(300),
|
||||
_ => {
|
||||
print_usage(Some("No countdown string specified"));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => Duration::from_secs(300),
|
||||
Ok(None) => {
|
||||
print_usage(Some("No countdown specified"));
|
||||
return 1;
|
||||
}
|
||||
Err(err) => {
|
||||
print_usage(Some(&format!("Unparsable countdown: {:?}", err)));
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
match *state.write().unwrap() {
|
||||
State::Running {
|
||||
@ -488,10 +514,12 @@ fn main() {
|
||||
}
|
||||
});
|
||||
|
||||
app.connect_open(move |app, files, args| {
|
||||
app.connect_open(move |app, _files, _args| {
|
||||
/*
|
||||
println!("called open");
|
||||
println!("files: {}", files.len());
|
||||
println!("args: {}", args);
|
||||
*/
|
||||
|
||||
app.activate();
|
||||
});
|
||||
@ -532,7 +560,7 @@ fn main() {
|
||||
let splash = splash.clone();
|
||||
async move {
|
||||
while let Ok(state) = gtk_rx.recv().await {
|
||||
println!("received state");
|
||||
// println!("received state");
|
||||
splash.set_state(state);
|
||||
}
|
||||
}
|
||||
@ -545,7 +573,7 @@ fn main() {
|
||||
loop {
|
||||
async_std::task::sleep(Duration::from_millis(1000 / 60)).await;
|
||||
state.write().unwrap().run(Instant::now());
|
||||
println!("state: {:?}", state.read().unwrap());
|
||||
// println!("state: {:?}", state.read().unwrap());
|
||||
let _ = gtk_tx.send(*state.read().unwrap()).await;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user