mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
cleanup
This commit is contained in:
parent
ea98a9798f
commit
12a9a03f1a
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user