clean up version string and include configure flags

This commit is contained in:
Simon Michael 2009-01-20 05:57:25 +00:00
parent 7bf18cd4f4
commit 8dcd53c9ba
3 changed files with 34 additions and 8 deletions

View File

@ -48,7 +48,7 @@ sampleledgers:
# ghc -e 'putStr $$ unlines $$ replicate 10000 "!include sample.ledger"' >sample10000.ledger
# ghc -e 'putStr $$ unlines $$ replicate 100000 "!include sample.ledger"' >sample10000.ledger
VERSION=`egrep 'versionno *=' Options.hs | perl -pe 's/.*"(.*?)"/\1/'`
VERSION=`egrep 'version *=' Options.hs | perl -pe 's/.*"(.*?)"/\1/'`
release:
cabal sdist && darcs tag $(VERSION) && cabal upload dist/hledger-$(VERSION).tar.gz

View File

@ -12,8 +12,33 @@ import Ledger.Types
import Ledger.Dates
versionno = "0.3.x"
version = printf "hledger version %s \n" versionno :: String
configflags = [
("vty",
#ifdef VTY
True
#else
False
#endif
)
,("ansi",
#ifdef ANSI
True
#else
False
#endif
)
]
versionmsg = "hledger " ++ version ++ configmsg ++ "\n"
version = "0.3.x"
configmsg
| null with && null without = ""
| (not $ null with) && (not $ null without) = " configured" ++ with ++ " and" ++ without
| otherwise = " configured" ++ with ++ without
where
with = punc "with" [f | (f,v) <- configflags, v]
without = punc "without" [f | (f,v) <- configflags, not v]
punc _ [] = ""
punc prefix ws = printf " %s %s" prefix (intercalate ", " ws)
ledgerdefault = "~/.ledger"
ledgerenvvar = "LEDGER"
timelogdefault = "~/.timelog"
@ -22,14 +47,15 @@ timeprogname = "hours"
usagehdr = "Usage: hledger [OPTION] COMMAND [ACCTPATTERNS] [-- DESCPATTERNS]\n" ++
"or: hours [OPTIONS] [PERIOD [COMMAND [PATTERNS]]]\n" ++
"\n" ++
"Options (before command, unless using --options-anywhere):"
usageftr = "\n" ++
"Commands (can be abbreviated):\n" ++
" balance - show account balances\n" ++
" print - show formatted ledger entries\n" ++
" register - show register transactions\n" ++
"\n" ++
"Options (before command, unless using --options-anywhere):"
usageftr = "\n" ++
"All dates can be y/m/d or ledger-style smart dates like \"last month\".\n" ++
"\n" ++
"Account and description patterns are regular expressions which filter by\n" ++
"account name and entry description. Prefix a pattern with - to negate it,\n" ++
"and separate account and description patterns with --.\n" ++
@ -54,7 +80,6 @@ options = [
"(where EXPR is 'dOP[DATE]', OP is <, <=, =, >=, >)")
,Option ['E'] ["empty"] (NoArg Empty) "balance report: show accounts with zero balance"
,Option ['R'] ["real"] (NoArg Real) "report only on real (non-virtual) transactions"
,Option [] ["options-anywhere"] (NoArg OptionsAnywhere) "allow options anywhere, use ^ to negate patterns"
,Option ['n'] ["collapse"] (NoArg Collapse) "balance report: no grand total"
,Option ['s'] ["subtotal"] (NoArg SubTotal) "balance report: show subaccounts"
,Option ['W'] ["weekly"] (NoArg WeeklyOpt) "register report: show weekly summary"
@ -63,7 +88,8 @@ options = [
,Option ['h'] ["help"] (NoArg Help) "show this help"
,Option ['v'] ["verbose"] (NoArg Verbose) "verbose test output"
,Option ['V'] ["version"] (NoArg Version) "show version"
,Option [] ["debug-no-ui"] (NoArg DebugNoUI) "when running in ui mode, don't display anything (mostly)"
,Option [] ["debug-no-ui"] (NoArg DebugNoUI) "run ui commands without no output"
,Option [] ["options-anywhere"] (NoArg OptionsAnywhere) "allow options anywhere on the command line"
]
where
filehelp = printf "ledger file; - means use standard input. Defaults\nto the %s environment variable or %s"

View File

@ -63,7 +63,7 @@ main = do
where
run cmd opts args
| Help `elem` opts = putStr $ usage
| Version `elem` opts = putStr version
| Version `elem` opts = putStr versionmsg
| cmd `isPrefixOf` "balance" = parseLedgerAndDo opts args balance
| cmd `isPrefixOf` "print" = parseLedgerAndDo opts args print'
| cmd `isPrefixOf` "register" = parseLedgerAndDo opts args register