simple --version option

This commit is contained in:
Simon Michael 2008-10-10 01:36:21 +00:00
parent 81ac9bcaa5
commit 2f59135953
2 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,6 @@
module Options ( module Options (
Opt(..), Opt(..),
usage, usage, version,
parseArguments, parseArguments,
ledgerFilePathFromOpts, ledgerFilePathFromOpts,
beginDateFromOpts, beginDateFromOpts,
@ -31,8 +31,8 @@ options = [
Option ['b'] ["begin"] (ReqArg Begin "yyyy/mm/dd") "report on entries from this date (inclusive)", Option ['b'] ["begin"] (ReqArg Begin "yyyy/mm/dd") "report on entries from this date (inclusive)",
Option ['e'] ["end"] (ReqArg End "yyyy/mm/dd") "report on entries to this date (exclusive)", Option ['e'] ["end"] (ReqArg End "yyyy/mm/dd") "report on entries to this date (exclusive)",
Option ['s'] ["showsubs"] (NoArg ShowSubs) "balance report: show subaccounts", Option ['s'] ["showsubs"] (NoArg ShowSubs) "balance report: show subaccounts",
Option ['h'] ["help","usage"] (NoArg Help) "show this help" Option ['h'] ["help","usage"] (NoArg Help) "show this help",
--Option ['V'] ["version"] (NoArg Version) "show version" Option ['V'] ["version"] (NoArg Version) "show version"
] ]
-- | An option value from a command-line flag. -- | An option value from a command-line flag.
@ -47,6 +47,8 @@ data Opt =
usage = usageInfo usagehdr options usage = usageInfo usagehdr options
version = "hledger version 0.1 alpha\n"
-- | Parse the command-line arguments into ledger options, ledger command -- | Parse the command-line arguments into ledger options, ledger command
-- name, and ledger command arguments -- name, and ledger command arguments
parseArguments :: IO ([Opt], String, [String]) parseArguments :: IO ([Opt], String, [String])

View File

@ -48,6 +48,7 @@ main = do
run cmd opts args run cmd opts args
where run cmd opts args where run cmd opts args
| Help `elem` opts = putStr usage | Help `elem` opts = putStr usage
| Version `elem` opts = putStr version
| cmd `isPrefixOf` "selftest" = selftest opts args | cmd `isPrefixOf` "selftest" = selftest opts args
| cmd `isPrefixOf` "print" = print_ opts args | cmd `isPrefixOf` "print" = print_ opts args
| cmd `isPrefixOf` "register" = register opts args | cmd `isPrefixOf` "register" = register opts args