hledger/extra/hledger-vty/Hledger/Vty/Options.hs
Simon Michael 1d957720e3 vty: make hledger-vty buildable again
Just for fun and curiousity, hledger-vty once again builds, with hledger
HEAD and GHC 7.10, and has a stack config. To see it once again in all
its glory:

$ cd extra/hledger-vty
$ stack install
$ hledger vty [-- ARGS]

[ci skip]
2015-08-11 19:16:58 -07:00

69 lines
1.9 KiB
Haskell

{-# LANGUAGE CPP #-}
{-|
-}
module Hledger.Vty.Options
where
import System.Console.CmdArgs
import System.Console.CmdArgs.Explicit
import Hledger.Cli hiding (progname,version,prognameandversion)
progname, version :: String
progname = "hledger-vty"
#ifdef VERSION
version = VERSION
#else
version = ""
#endif
prognameandversion :: String
prognameandversion = progname ++ " " ++ version :: String
vtyflags = [
flagNone ["debug-vty"] (\opts -> setboolopt "rules-file" opts) "run with no terminal output, showing console"
]
--vtymode :: Mode [([Char], [Char])]
vtymode = (mode "hledger-vty" [("command","vty")]
"browse accounts, postings and entries in a full-window curses interface"
(argsFlag "[PATTERNS]") []){
modeGroupFlags = Group {
groupUnnamed = vtyflags
,groupHidden = []
,groupNamed = [(generalflagsgroup1)]
}
,modeHelpSuffix=[
-- "Reads your ~/.hledger.journal file, or another specified by $LEDGER_FILE or -f, and starts the full-window curses ui."
]
}
-- hledger-vty options, used in hledger-vty and above
data VtyOpts = VtyOpts {
debug_vty_ :: Bool
,cliopts_ :: CliOpts
} deriving (Show)
defvtyopts = VtyOpts
def
def
-- instance Default CliOpts where def = defcliopts
toVtyOpts :: RawOpts -> IO VtyOpts
toVtyOpts rawopts = do
cliopts <- rawOptsToCliOpts rawopts
return defvtyopts {
debug_vty_ = boolopt "debug-vty" rawopts
,cliopts_ = cliopts
}
checkVtyOpts :: VtyOpts -> IO VtyOpts
checkVtyOpts opts = do
checkCliOpts $ cliopts_ opts
return opts
getHledgerVtyOpts :: IO VtyOpts
getHledgerVtyOpts = processArgs vtymode >>= return . decodeRawOpts >>= toVtyOpts >>= checkVtyOpts