Arnau478 / hevi

Hex viewer
https://arnau478.github.io/hevi/
GNU General Public License v3.0
56 stars 2 forks source link

Implement `--version` arg #13

Closed Reokodoku closed 2 months ago

Reokodoku commented 2 months ago

This PR adds the --version argument (as well as -v) to get information about the version of hevi built.


When git is available, the build system tries to get the information to generate the version string from git describe --tags. The format of the version taken from git is x.x.x-dev.n+h, where n is the commit number (starting with the last tag) and where h is the hash of the last commit.

If git is unavailable or an error occurs, the version string defaults to the one written in build.zig.

Also, the version is not taken from build.zig.zon because there is no function or variable to get it from there (the only way is to parse the zon file, but I don't think that is necessary).

Arnau478 commented 2 months ago

Also, the version is not taken from build.zig.zon because there is no function or variable to get it from there (the only way is to parse the zon file, but I don't think that is necessary).

As a side note, I was actually considering doing that, as parsing it would be pretty easy. Also, https://github.com/ziglang/zig/issues/14531 won't be implemented until zig 0.14.0, so...

Arnau478 commented 2 months ago

Looks pretty good to me. Just a small thing: when git is not available, it builds with the version being the one in build.zig.zon (no -dev) or anything. Sure, it cannot get the commit number nor id, but it can add a single -dev, to make it clear that it's not a release build.