Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Hledger.Cli
Description
This is the root module of the hledger
package,
providing hledger's command-line interface.
The main function,
commands,
command-line options,
and utilities useful to other hledger command-line programs
are exported.
It also re-exports hledger-lib:Hledger
and cmdargs:System.Concole.CmdArgs.Explicit
See also:
- hledger-lib:Hledger
- The README files
- The high-level developer docs
About
hledger - a fast, reliable, user-friendly plain text accounting tool. Copyright (c) 2007-2023 Simon Michael simon@joyful.com and contributors Released under GPL version 3 or later.
hledger is a Haskell rewrite of John Wiegley's "ledger". It generates financial reports from a plain text general journal. You can use the command line:
$ hledger
or ghci:
$ make ghci ghci> Right j <- runExceptT $ readJournalFile definputopts "examples/sample.journal" -- or: j <- defaultJournal ghci> :t j j :: Journal ghci> stats defcliopts j Main file : examples/sample.journal Included files : Transactions span : 2008-01-01 to 2009-01-01 (366 days) Last transaction : 2008-12-31 (733772 days from now) Transactions : 5 (0.0 per day) Transactions last 30 days: 0 (0.0 per day) Transactions last 7 days : 0 (0.0 per day) Payees/descriptions : 5 Accounts : 8 (depth 3) Commodities : 1 ($) Market prices : 0 () Run time (throughput) : 1695276900.00s (0 txns/s) ghci> balance defcliopts j $1 assets:bank:saving $-2 assets:cash $1 expenses:food $1 expenses:supplies $-1 income:gifts $-1 income:salary $1 liabilities:debts -------------------- 0 ghci>
etc.
Synopsis
- prognameandversion :: String
- versionString :: ProgramName -> PackageVersion -> String
- main :: IO ()
- mainmode :: [Name] -> Mode RawOpts
- argsToCliOpts :: [String] -> [String] -> IO CliOpts
- module Hledger.Cli.CliOptions
- module Hledger.Cli.Commands
- module Hledger.Cli.DocFiles
- module Hledger.Cli.Utils
- module Hledger.Cli.Version
- type Help = String
- data Group a = Group {
- groupUnnamed :: [a]
- groupHidden :: [a]
- groupNamed :: [(Help, [a])]
- data Complete
- = CompleteValue String
- | CompleteFile String FilePath
- | CompleteDir String FilePath
- data Arg a = Arg {
- argValue :: Update a
- argType :: FlagHelp
- argRequire :: Bool
- data Flag a = Flag {}
- type FlagHelp = String
- data Mode a = Mode {
- modeGroupModes :: Group (Mode a)
- modeNames :: [Name]
- modeValue :: a
- modeCheck :: a -> Either String a
- modeReform :: a -> Maybe [String]
- modeExpandAt :: Bool
- modeHelp :: Help
- modeHelpSuffix :: [String]
- modeArgs :: ([Arg a], Maybe (Arg a))
- modeGroupFlags :: Group (Flag a)
- data HelpFormat
- data FlagInfo
- = FlagReq
- | FlagOpt String
- | FlagOptRare String
- | FlagNone
- class Remap (m :: Type -> Type) where
- remap :: (a -> b) -> (b -> (a, a -> b)) -> m a -> m b
- type Update a = String -> a -> Either String a
- process :: Mode a -> [String] -> Either String a
- flagNone :: [Name] -> (a -> a) -> Help -> Flag a
- flagReq :: [Name] -> Update a -> FlagHelp -> Help -> Flag a
- mode :: Name -> a -> Help -> Arg a -> [Flag a] -> Mode a
- flagOpt :: String -> [Name] -> Update a -> FlagHelp -> Help -> Flag a
- flagArg :: Update a -> FlagHelp -> Arg a
- toGroup :: [a] -> Group a
- helpText :: [String] -> HelpFormat -> Mode a -> [Text]
- expandArgsAt :: [String] -> IO [String]
- modes :: String -> a -> Help -> [Mode a] -> Mode a
- complete :: Mode a -> [String] -> (Int, Int) -> [Complete]
- joinArgs :: [String] -> String
- splitArgs :: String -> [String]
- checkMode :: Mode a -> Maybe String
- flagBool :: [Name] -> (Bool -> a -> a) -> Help -> Flag a
- fromFlagOpt :: FlagInfo -> String
- fromGroup :: Group a -> [a]
- modeEmpty :: a -> Mode a
- modeFlags :: Mode a -> [Flag a]
- modeModes :: Mode a -> [Mode a]
- parseBool :: String -> Maybe Bool
- remap2 :: Remap m => (a -> b) -> (b -> a) -> m a -> m b
- remapUpdate :: (a -> b) -> (b -> (a, a -> b)) -> Update a -> Update b
- flagHelpFormat :: (HelpFormat -> TextFormat -> a -> a) -> Flag a
- flagHelpSimple :: (a -> a) -> Flag a
- flagNumericVersion :: (a -> a) -> Flag a
- flagVersion :: (a -> a) -> Flag a
- flagsVerbosity :: (Verbosity -> a -> a) -> [Flag a]
- processArgs :: Mode a -> IO a
- processValue :: Mode a -> [String] -> a
- processValueIO :: Mode a -> [String] -> IO a
Documentation
prognameandversion :: String Source #
The program name and version string for this build of the hledger tool, including any git info available at build time.
versionString :: ProgramName -> PackageVersion -> String Source #
A helper to generate the best version string we can from the given program name and package version strings, current os and architecture, and any git info available at build time (commit hash, commit date, branch name, patchlevel since latest release tag for that program's package). Typically called for programs "hledger", "hledger-ui", or "hledger-web".
The git info changes whenever any file in the repository changes. Keeping this template haskell call here and not down in Hledger.Cli.Version helps reduce the number of modules recompiled.
mainmode :: [Name] -> Mode RawOpts Source #
The overall cmdargs mode describing hledger's command-line options and subcommands.
argsToCliOpts :: [String] -> [String] -> IO CliOpts Source #
Parse hledger CLI options from these command line arguments and add-on command names, or raise any error.
Re-exports
module Hledger.Cli.CliOptions
module Hledger.Cli.Commands
module Hledger.Cli.DocFiles
module Hledger.Cli.Utils
module Hledger.Cli.Version
System.Console.CmdArgs.Explicit
Constructors
Group | |
Fields
|
Constructors
CompleteValue String | |
CompleteFile String FilePath | |
CompleteDir String FilePath |
Instances
Show Complete | |
Eq Complete | |
Ord Complete | |
Defined in System.Console.CmdArgs.Explicit.Complete |
Constructors
Flag | |
Constructors
Mode | |
Fields
|
data HelpFormat #
Instances
Constructors
FlagReq | |
FlagOpt String | |
FlagOptRare String | |
FlagNone |
Instances
Show FlagInfo | |
Eq FlagInfo | |
Ord FlagInfo | |
Defined in System.Console.CmdArgs.Explicit.Type |
class Remap (m :: Type -> Type) where #
Instances
Remap Arg | |
Defined in System.Console.CmdArgs.Explicit.Type | |
Remap Flag | |
Defined in System.Console.CmdArgs.Explicit.Type | |
Remap Mode | |
Defined in System.Console.CmdArgs.Explicit.Type |
helpText :: [String] -> HelpFormat -> Mode a -> [Text] #
expandArgsAt :: [String] -> IO [String] #
fromFlagOpt :: FlagInfo -> String #
remapUpdate :: (a -> b) -> (b -> (a, a -> b)) -> Update a -> Update b #
flagHelpFormat :: (HelpFormat -> TextFormat -> a -> a) -> Flag a #
flagHelpSimple :: (a -> a) -> Flag a #
flagNumericVersion :: (a -> a) -> Flag a #
flagVersion :: (a -> a) -> Flag a #
flagsVerbosity :: (Verbosity -> a -> a) -> [Flag a] #
processArgs :: Mode a -> IO a #
processValue :: Mode a -> [String] -> a #
processValueIO :: Mode a -> [String] -> IO a #