hledger-1.31: Command-line interface for the hledger accounting system

Safe Haskell | Safe-Inferred
Language | Haskell2010

Hledger.Cli.Version

Synopsis

- type ProgramName = String
- type PackageVersion = String
- type VersionString = String
- packageversion :: PackageVersion
- progname :: ProgramName
- versionStringWith :: Either String GitInfo -> ProgramName -> PackageVersion -> VersionString

# Documentation

type ProgramName = String #

type PackageVersion = String #

type VersionString = String #

packageversion :: PackageVersion #

The "1.31" string defined with -D in this package's package.yaml/.cabal file (by Shake setversion), if any. Normally a dotted number string with 1-3 components.

progname :: ProgramName #

The name of this package's main executable.

versionStringWith :: Either String GitInfo -> ProgramName -> PackageVersion -> VersionString #

Given possible git state info from the build directory (or an error message, which is ignored), the name of a program (executable) in the currently building package, and the package's version, make a complete version string. Here is the logic:

- Program name, OS and architecture are always shown.
- The package version is always shown.
- If there is git info at build time, the latest commit hash and commit date are shown, and (TODO, requires githash to use -uno for giDirty): if the working copy has uncommitted changes a + sign is appended.
- (TODO, requires adding --match support to githash: If there are tags matching THISPKG-[0-9]*, the latest one is used to calculate patch level (number of commits since tag), and if non-zero, it and the branch name are shown.)

Some example outputs:

- A homebrew binary, not built in git repo: hledger-ui 1.24, mac-aarch64
- A CI release build, built in git repo at release tag: hledger-ui 1.24.1-g455b35293-20211210, mac-x86_64
- (TODO) A dev build, built in git repo: hledger-ui 1.24.1+1-g4abd8ef10-20211210 (1.24-branch), mac-x86_64

This function requires git log to show the default (rfc2822-style) date format, so that must not be overridden by a log.date git config variable.