hbsd-update: Add option for getting machine-readable output
Created by: Follpvosten
While writing shell scripts and other tools using hbsd-update, I noticed that it is sometimes either hard to impossible to actually parse its output, or it works, but looks weird and as if my scripts around it could break with any update.
It would be nice to have a command which produces more machine-readable output; for example, a --json
flag (as json is often used in tooling around FreeBSD - well, it was mostly around TrueOS. But it's also a stable and reliable format, tho not too well-suited to be written by humans), but any format would be okay, really, it just has to be well-supported and the API should be stable.
For example, on running hbsd-update -C --json
, the output to stdout might look something like:
{
"local_version": "hbsd-v1200060-a5c1250e0e66e2606b30fe4bc94265fee1038b34",
"remote_version": "hbsd-v1200060-a5c1250e0e66e2606b30fe4bc94265fee1038b34"
}
Additionally, and I don't know if this would be a good idea, but maybe there could also be a flag like --fail-if-no-updates
for -C
, which would make hbsd-update return an error status code if there are no updates available (maybe a specific code like the HTTP status code 304 - Not Modified, but that's just an idea). This could be a problem if it errors for a different reason, but either way you likely don't want to update if this command fails.