ui: --register starts in the register screen

This commit is contained in:
Simon Michael 2015-08-28 08:48:40 -07:00
parent eefa9c42a3
commit 4f351d6c9c
2 changed files with 13 additions and 3 deletions

View File

@ -18,7 +18,7 @@ import Control.Monad
-- import Data.List
import Data.Maybe
-- import Data.Time.Calendar
-- import Safe
import Safe
import System.Exit
import qualified Graphics.Vty as V
@ -31,7 +31,7 @@ import Hledger.UI.UITypes
-- import Hledger.UI.UIUtils
import Hledger.UI.Theme
import Hledger.UI.AccountsScreen as AS
-- import Hledger.UI.RegisterScreen as RS
import Hledger.UI.RegisterScreen as RS
----------------------------------------------------------------------
@ -60,9 +60,18 @@ runBrickUi opts j = do
d <- getCurrentDay
let
-- XXX move this stuff into Options, UIOpts
theme = maybe defaultTheme (fromMaybe defaultTheme . getTheme) $
maybestringopt "theme" $ rawopts_ $ cliopts_ opts
scr = AS.screen
mshowacct = maybestringopt "register" $ rawopts_ $ cliopts_ opts
scr = case mshowacct of
Nothing -> AS.screen
Just apat -> RS.screen{rsAcct=acct}
where
acct = headDef
(error' $ "--register "++apat++" did not match any account")
$ filter (regexMatches apat) $ journalAccountNames j
st = (sInitFn scr) d
AppState{
aopts=opts

View File

@ -25,6 +25,7 @@ prognameandversion = progname ++ " " ++ version :: String
uiflags = [
-- flagNone ["debug-ui"] (\opts -> setboolopt "rules-file" opts) "run with no terminal output, showing console"
flagReq ["theme"] (\s opts -> Right $ setopt "theme" s opts) "THEME" ("use this custom display theme ("++intercalate ", " themeNames++")")
,flagReq ["register"] (\s opts -> Right $ setopt "register" s opts) "ACCTREGEX" "start in the (first) matched account's register"
,flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show full account names, unindented"
-- ,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "with --flat, omit this many leading account name components"
-- ,flagReq ["format"] (\s opts -> Right $ setopt "format" s opts) "FORMATSTR" "use this custom line format"