{-# LANGUAGE CPP #-}{-
Version-related utilities. See the Makefile for details of our version
numbering policy.
-}moduleHledger.Cli.Version(version,progversionstr,binaryfilename)whereimportData.ListimportSystem.Info(os,arch)importText.PrintfimportHledger.Utils-- version and PATCHLEVEL are set by the make processversion::Stringversion="0.15.0"patchlevel::String#ifdef PATCHLEVELpatchlevel="."++show(PATCHLEVEL::Int)-- must be numeric !#elsepatchlevel=""#endifbuildversion::Stringbuildversion=version++patchlevel::String-- | Given a program name, return a human-readable version string. For-- development builds, at least non-cabal builds, the patch level (ie the-- number of patches applied since last release tag) will also be-- included.progversionstr::String->Stringprogversionstrprogname=progname++"-"++versionstr++configmsgwhereversionstr=prettify$splitAtElement'.'buildversionwhereprettify(major:minor:bugfix:patches:[])=printf"%s.%s%s%s"majorminorbugfix'patches'wherebugfix'|bugfix`elem`["0"{-,"98","99"-}]=""|otherwise='.':bugfixpatches'|patches/="0"="+"++patches|otherwise=""prettifys=intercalate"."sconfigmsg|nullbuildflags=""|otherwise=" with "++intercalate", "buildflagsbuildflags=[]-- | Given a program name, return a precise platform-specific executable-- name suitable for naming downloadable binaries. Can raise an error if-- the version and patch level was not defined correctly at build time.binaryfilename::String->Stringbinaryfilenameprogname=prettify$splitAtElement'.'buildversionwhereprettify(major:minor:bugfix:patches:[])=printf"%s-%s.%s%s%s-%s-%s%s"prognamemajorminorbugfix'patches'os'archsuffixwherebugfix'|bugfix`elem`["0"{-,"98","99"-}]=""|otherwise='.':bugfixpatches'|patches/="0"='+':patches|otherwise=""(os',suffix)|os=="darwin"=("mac","")|os=="mingw32"=("windows",".exe")|otherwise=(os,"")prettify(major:minor:bugfix:[])=prettify[major,minor,bugfix,"0"]prettify(major:minor:[])=prettify[major,minor,"0","0"]prettify(major:[])=prettify[major,"0","0","0"]prettify[]=error'"VERSION is empty, please fix"prettify_=error'"VERSION has too many components, please fix"