From dfc0095fed31518353522d7097f9b024a934b641 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 13 Sep 2019 07:54:58 -0700 Subject: [PATCH] import: create the journal if missing, like the add command Streamlines import/migration instructions. --- hledger/Hledger/Cli/Main.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hledger/Hledger/Cli/Main.hs b/hledger/Hledger/Cli/Main.hs index 2160b3b72..27940d119 100644 --- a/hledger/Hledger/Cli/Main.hs +++ b/hledger/Hledger/Cli/Main.hs @@ -171,12 +171,11 @@ main = do -- builtin commands | Just (cmdmode, cmdaction) <- findCommand cmd = - (case cmd of + (case True of -- these commands should not require or read the journal - "test" -> cmdaction opts journallesserror - "help" -> cmdaction opts journallesserror - -- this command should create the journal if missing - "add" -> do + _ | cmd `elem` ["test","help"] -> cmdaction opts journallesserror + -- these commands should create the journal if missing + _ | cmd `elem` ["add","import"] -> do (ensureJournalFileExists =<< (head <$> journalFilePathFromOpts opts)) withJournalDo opts (cmdaction opts) -- other commands read the journal and should fail if it's missing