diff --git a/Options.hs b/Options.hs index 693ce1229..075b587be 100644 --- a/Options.hs +++ b/Options.hs @@ -8,7 +8,7 @@ import Data.Maybe (fromMaybe) import Utils -usage = "Usage: hledger [OPTIONS] "++commands++" [ACCTPATTERNS] [-- DESCPATTERNS]\nOptions:" +usagehdr = "Usage: hledger [OPTIONS] "++commands++" [ACCTPATTERNS] [-- DESCPATTERNS]\nOptions:" commands = "register|balance" defaultcmd = "register" ledgerFilePath = findFileFromOpts "~/ledger.dat" "LEDGER" @@ -31,7 +31,7 @@ parseOptions argv = case getOpt RequireOrder options argv of (opts,[],[]) -> return (opts, [defaultcmd]) (opts,args,[]) -> return (opts, args) - (_,_,errs) -> ioError (userError (concat errs ++ showusage)) + (_,_,errs) -> ioError (userError (concat errs ++ usage)) -- testoptions RequireOrder ["foo","-v"] -- testoptions Permute ["foo","-v"] @@ -42,9 +42,9 @@ parseOptions argv = testoptions order cmdline = putStr $ case getOpt order options cmdline of (o,n,[] ) -> "options=" ++ show o ++ " args=" ++ show n - (_,_,errs) -> concat errs ++ showusage + (_,_,errs) -> concat errs ++ usage -showusage = usageInfo usage options +usage = usageInfo usagehdr options -- find a file path from options, an env var or a default value findFileFromOpts :: FilePath -> String -> [Flag] -> IO String diff --git a/hledger.hs b/hledger.hs index 5be8dafcd..d9aea5227 100644 --- a/hledger.hs +++ b/hledger.hs @@ -19,6 +19,7 @@ hledger Entry Transaction AccountName + Amount BasicTypes Utils @@ -48,7 +49,7 @@ main = do | cmd `isPrefixOf` "register" = register opts args | cmd `isPrefixOf` "balance" = balance opts args | cmd `isPrefixOf` "test" = test - | otherwise = putStr showusage + | otherwise = putStr usage -- commands