Skip to content

Commit

Permalink
uair: return exit code 1 on failure
Browse files Browse the repository at this point in the history
closes #17
  • Loading branch information
metent committed Jan 4, 2024
1 parent be7d23b commit 9b1fbe1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- New `uairctl` flag for `listen` subcommand: `-e` or `--exit`. Allows to output remaining time and exit the listening instance immediately.

### Fixed

- `uair` now returns exit code 1 on failure.

### v0.6.1

#### Fixed
Expand Down
6 changes: 0 additions & 6 deletions docs/uair.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ The number of pomodoro sessions and their properties can be specified by an uair
*command*
Command which is run when the session finishes. See COMMAND ENVIRONMENT section for information on environment variables which are passed to the command.

*before*
String which is printed before the remaining time string. (Deprecated)

*after*
String which is printed after the remaining time string. (Deprecated)

*format*
Specifies the format in which text is printed each second. See FORMAT SPECIFIERS section for details.

Expand Down
14 changes: 10 additions & 4 deletions src/bin/uair/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod timer;

use std::env;
use std::io::{self, Write};
use std::process::ExitCode;
use uair::get_socket_path;
use argh::FromArgs;
use futures_lite::{FutureExt, StreamExt};
Expand All @@ -14,7 +15,7 @@ use signal_hook::consts::signal::*;
use signal_hook_async_std::Signals;
use crate::app::App;

fn main() {
fn main() -> ExitCode {
let args: Args = argh::from_env();
if args.version {
_ = write!(
Expand All @@ -23,7 +24,7 @@ fn main() {
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
);
return;
return ExitCode::SUCCESS;
}

let enable_stderr = args.log != "-";
Expand All @@ -33,14 +34,19 @@ fn main() {
Err(err) => {
error!("{}", err);
if enable_stderr { eprintln!("{}", err) }
return
return ExitCode::FAILURE;
}
};

if let Err(err) = async_io::block_on(app.run().or(catch_term_signals())) {
error!("{}", err);
if enable_stderr { eprintln!("{}", err) }
if enable_stderr {
eprintln!("{}", err);
return ExitCode::FAILURE;
}
}

return ExitCode::SUCCESS;
}

#[derive(FromArgs)]
Expand Down

0 comments on commit 9b1fbe1

Please sign in to comment.