From 173f61bee0be08c753d71a212547df31733cca80 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 12 Jan 2023 23:58:17 -1000 Subject: [PATCH] dev: Commands: cleanup, fix harmless bug in command finding --- hledger/Hledger/Cli/Commands.hs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hledger/Hledger/Cli/Commands.hs b/hledger/Hledger/Cli/Commands.hs index 3e7710f97..89ab901d7 100644 --- a/hledger/Hledger/Cli/Commands.hs +++ b/hledger/Hledger/Cli/Commands.hs @@ -103,7 +103,7 @@ builtinCommands = [ ,(closemode , close) ,(codesmode , codes) ,(commoditiesmode , commodities) - ,(descriptionsmode , descriptions) + ,(descriptionsmode , descriptions) ,(diffmode , diff) ,(filesmode , files) ,(helpmode , help') @@ -187,10 +187,14 @@ commandsList progversion othercmds highlight0 = (if highlight then (map (\s -> if "+" `isPrefixOf` s then highlightAddon (' ' : drop 1 s) else s)) else id) $ map (bold'.accent) _banner_smslant ++ [ - -- keep synced with hledger.m4.md > PART 4: COMMANDS, Hledger/Cli/Commands > commands.m4 --> - -----------------------------------------80------------------------------------- - "" - ,accent progversion + -- Keep the following synced with: + -- commands.m4 + -- hledger.m4.md -> Commands + -- commandsFromCommandsList. Only commands should begin with space or plus. + "-------------------------------------------------------------------------------" + ,progversion + ,"Usage: hledger COMMAND [OPTIONS] [-- ADDONCMDOPTIONS]" + ,"Commands (+ addons found in $PATH):" ,"" ,"Usage: " ++ bold' "hledger CMD [OPTS] [-- ADDONCMDOPTS]" ,"" @@ -296,11 +300,10 @@ 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. commandsFromCommandsList :: [String] -> [String] -commandsFromCommandsList s = - [w | c:l <- s, c `elem` [' ','+'], let w:_ = words l] +commandsFromCommandsList s = [w | c:l <- s, c `elem` [' ','+'], let w:_ = words l] knownCommands :: [String] -knownCommands = sort . commandsFromCommandsList . drop 1 $ commandsList progname [] False -- progname will not be seen +knownCommands = sort . commandsFromCommandsList $ commandsList progname [] False -- progname will not be seen -- | Print the commands list, modifying the template above based on -- the currently available addons. Missing addons will be removed, and