lib: Hledger.Cli.Commands: findCommand -> findBuiltinCommand

This commit is contained in:
Simon Michael 2023-05-18 07:06:04 -10:00
parent 3961dbc044
commit ae4f58beb7
2 changed files with 5 additions and 5 deletions

View File

@ -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 $

View File

@ -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