From ae4f58beb7d1ca26b05675e37cc8ae77ba2a90fc Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 18 May 2023 07:06:04 -1000 Subject: [PATCH] lib: Hledger.Cli.Commands: findCommand -> findBuiltinCommand --- hledger/Hledger/Cli/Commands.hs | 8 ++++---- hledger/Hledger/Cli/Main.hs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hledger/Hledger/Cli/Commands.hs b/hledger/Hledger/Cli/Commands.hs index 860f06ced..b5ff0e5a2 100644 --- a/hledger/Hledger/Cli/Commands.hs +++ b/hledger/Hledger/Cli/Commands.hs @@ -10,10 +10,10 @@ the export list, the import list, builtinCommands, commandsList. {-# LANGUAGE TemplateHaskell #-} module Hledger.Cli.Commands ( - findCommand ,testcmd ,builtinCommands ,builtinCommandNames + ,findBuiltinCommand ,printCommandsList ,tests_Hledger_Cli ,module Hledger.Cli.Commands.Accounts @@ -294,9 +294,6 @@ multicol width strs = builtinCommandNames :: [String] builtinCommandNames = concatMap (modeNames . fst) builtinCommands --- | Look up a builtin command's mode and action by exact command name or alias. -findCommand :: String -> Maybe (Mode RawOpts, CliOpts -> Journal -> IO ()) -findCommand cmdname = find (elem cmdname . modeNames . fst) builtinCommands -- | Extract the command names from commandsList: the first word -- of lines beginning with a space or + sign. @@ -309,6 +306,9 @@ knownCommands = sort . commandsFromCommandsList $ commandsList progname [] False -- | Print the commands list, modifying the template above based on -- the currently available addons. Missing addons will be removed, and -- extra addons will be added under Misc. +-- | Look up a builtin command's mode and action by exact command name or alias. +findBuiltinCommand :: String -> Maybe (Mode RawOpts, CliOpts -> Journal -> IO ()) +findBuiltinCommand cmdname = find (elem cmdname . modeNames . fst) builtinCommands printCommandsList :: String -> [String] -> IO () printCommandsList progversion addonsFound = pager . unlines . concatMap adjustline $ diff --git a/hledger/Hledger/Cli/Main.hs b/hledger/Hledger/Cli/Main.hs index 7e154dd6e..aff725f07 100644 --- a/hledger/Hledger/Cli/Main.hs +++ b/hledger/Hledger/Cli/Main.hs @@ -180,7 +180,7 @@ main = do | isBadCommand = badCommandError -- builtin commands - | Just (cmdmode, cmdaction) <- findCommand cmd = + | Just (cmdmode, cmdaction) <- findBuiltinCommand cmd = (case True of -- these commands should not require or read the journal _ | cmd `elem` ["test","help"] -> cmdaction opts journallesserror