pstop icon indicating copy to clipboard operation
pstop copied to clipboard

Add version CLI option

Open eabase opened this issue 6 months ago • 2 comments

Please add a -V CLI option to find the installed version.

eabase avatar May 10 '26 20:05 eabase

Hey, thanks for the suggestion. This is now implemented and pushed to master.

Both -V and --version work, and I went a step further than a plain version number. Since you might want to know exactly what you are running (especially when reporting issues), it also prints the precise git commit the binary was built from, along with the commit date:

> pstop -V
pstop 0.5.4 (f822665 2026-07-13)

The htop alias forwards to the same thing, so htop -V works too. It is also listed in pstop --help now.

A few notes on how it works under the hood:

  • The commit is captured at compile time by a small build.rs, so there is zero runtime cost and no extra dependencies.

  • If the binary was built from a working tree with uncommitted changes, it appends a , dirty marker, so you can always tell whether a build corresponds cleanly to a published commit:

    pstop 0.5.4 (f822665 2026-07-13, dirty)
    
  • If someone builds from a source tarball with no git history (for example a crates.io build), it degrades gracefully to pstop 0.5.4 (unknown commit) instead of failing the build.

This will ship in the next release. Let me know if the format works for you or if you would prefer something different.

psmux avatar Jul 13 '26 16:07 psmux

Quick verification pass before closing. Built master today and both spellings work, including through the htop alias:

> pstop -V
pstop 0.5.4 (c9004da 2026-09-23)
> htop --version
pstop 0.5.4 (c9004da 2026-09-23)

It is also listed in pstop --help. The implementation is f822665 (the build.rs that bakes in the commit hash and date at compile time, with the dirty marker and the unknown commit fallback described above).

Closing as done; it ships with the next release. Thanks @eabase!

psmux avatar Sep 23 '26 08:09 psmux