hledger
Safe HaskellNone
LanguageGHC2021

Hledger.Cli.Commands

Description

hledger's built-in commands, and helpers for printing the commands list.

New built-in commands should be added in four places below: the export list, the import list, builtinCommands, commandsListSections.

Synopsis

Documentation

commands :: CliOpts -> Journal -> IO () Source #

Display the commands list, limited to the categories selected by --builtins--addons--aliases. Only the selected categories are looked up: the addons in PATH, and the command aliases in the config file.

mainmode :: [Name] -> Mode RawOpts Source #

The overall cmdargs mode describing hledger's command-line options and subcommands. The names of known addons are provided so they too can be recognised as commands.

runUnitTests :: String -> IO () Source #

Run the hledger and hledger-lib packages' unit tests (for --test), or just those whose names match the given tasty pattern, if it is non-empty. Defined here for easy access to other modules' tests. They run in a single thread: they take only milliseconds, and running them in parallel occasionally crashes or hangs on aarch64 macOS, apparently from a GHC runtime bug (seen with GHC 9.12 and 9.14; https://gitlab.haskell.org/ghc/ghc/-/issues/28001).

builtinCommands :: [(Mode RawOpts, CliOpts -> Journal -> IO ())] Source #

The cmdargs subcommand mode (for command-line parsing) and IO action (for doing the command's work) for each builtin command. Command actions take parsed CLI options and a (lazy) finalised journal.

builtinCommandNames :: [String] Source #

All names and aliases of the builtin commands.

knownAddonCommandNames :: [String] Source #

Canonical names of the known addon commands which have a slot in the commands list, in alphabetical order.

findBuiltinCommand :: String -> Maybe (Mode RawOpts, CliOpts -> Journal -> IO ()) Source #

Look up a builtin command's mode and action by exact command name or alias.

knownCommands :: [String] Source #

Canonical names of all commands which have a slot in the commands list, in alphabetical order. These include the builtin commands and the known addon commands.

data CommandCategories Source #

The three categories of command which the commands list can show: the commands built in to hledger, the addon commands installed in PATH, and the command aliases defined in the config file.

Constructors

CommandCategories 

Fields

commandCategories :: RawOpts -> CommandCategories Source #

Which command categories are selected by the --builtins, --addons and --aliases flags in these options. Each of those flags limits the commands list to one category; with none of them, all categories are shown.

printCommandsList :: CommandCategories -> [String] -> [(CommandAlias, CommandLine)] -> IO () Source #

Print the commands list, with a pager if appropriate: the selected categories of command, customised with the addons installed in PATH and the command aliases defined in the config file.