From 4f351d6c9cbb7b8c1b81529cc4d2f57173706182 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 28 Aug 2015 08:48:40 -0700 Subject: [PATCH] ui: --register starts in the register screen --- hledger-ui/Hledger/UI/Main.hs | 15 ++++++++++++--- hledger-ui/Hledger/UI/Options.hs | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index e75273ce1..3e3557df5 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -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 diff --git a/hledger-ui/Hledger/UI/Options.hs b/hledger-ui/Hledger/UI/Options.hs index f8a6a4095..5937568d5 100644 --- a/hledger-ui/Hledger/UI/Options.hs +++ b/hledger-ui/Hledger/UI/Options.hs @@ -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"