Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/uffs-broker/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ fn print_usage() {
eprintln!(" --start Start the service (waits for RUNNING)");
eprintln!(" --stop Stop the service (waits for STOPPED)");
eprintln!(" --run Run in foreground (debugging)");
eprintln!(" --version Print version (also -V)");
}

/// Run the broker in foreground mode.
Expand Down
24 changes: 23 additions & 1 deletion crates/uffs-broker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
//! uffs-broker --start # Start the service
//! uffs-broker --stop # Stop the service
//! uffs-broker --run # Run in foreground (for debugging)
//! uffs-broker --version # Print version (also -V)
//! ```
//!
//! On non-Windows platforms, this binary prints an error and exits.
//! On non-Windows platforms, every subcommand except `--version` prints an
//! error and exits.

// `broker` is gated to `#[cfg(windows)]` because the entire module
// (Win32 named-pipe service, OpenProcess, DuplicateHandle, audit log,
Expand Down Expand Up @@ -45,6 +47,19 @@ mod broker;
`--install` failed with NO output). stderr always reaches the operator."
)]
fn main() {
// `--version` / `-V` is handled here, before the Windows service dispatch,
// so it works on every platform and exits 0. The self-update version probe
// runs `<bin> --version` and parses the output; without this arm the broker
// fell through to its usage text and the probe reported the broker as `?`
// (every other UFFS binary prints a version, so it was the odd one out).
if std::env::args()
.skip(1)
.any(|arg| arg == "--version" || arg == "-V")
{
print_version();
return;
}

#[cfg(windows)]
{
if let Err(run_err) = broker::run() {
Expand All @@ -61,3 +76,10 @@ fn main() {
std::process::exit(1);
}
}

/// Print `uffs-broker <version>` to stdout, matching the `uffs <version>`
/// shape the other binaries use so the self-update version probe parses it.
#[expect(clippy::print_stdout, reason = "intentional version output")]
fn print_version() {
println!("uffs-broker {}", env!("CARGO_PKG_VERSION"));
}
3 changes: 3 additions & 0 deletions crates/uffs-cli/src/commands/update/binaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ mod tests {
fn parses_named_version_line() {
assert_eq!(parse_version("uffs 0.6.2").as_deref(), Some("0.6.2"));
assert_eq!(parse_version("uffsd 0.6.10\n").as_deref(), Some("0.6.10"));
// The broker prints a hyphenated name; the hyphen must not be mistaken
// for part of the version token (else its version probes back as `?`).
assert_eq!(parse_version("uffs-broker 0.6.9").as_deref(), Some("0.6.9"));
}

#[test]
Expand Down
Loading