print,reg,balcmds: list output formats accurately in --help (#689)
Also: - tweak the unsupported output format message - Hledger.Cli.CliOptions no longer exports outputflags
This commit is contained in:
parent
5f1a864c20
commit
61bec588d2
@ -15,7 +15,7 @@ module Hledger.Cli.CliOptions (
|
|||||||
hiddenflags,
|
hiddenflags,
|
||||||
inputflags,
|
inputflags,
|
||||||
reportflags,
|
reportflags,
|
||||||
outputflags,
|
-- outputflags,
|
||||||
outputFormatFlag,
|
outputFormatFlag,
|
||||||
outputFileFlag,
|
outputFileFlag,
|
||||||
generalflagsgroup1,
|
generalflagsgroup1,
|
||||||
@ -192,9 +192,18 @@ hiddenflags = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
-- | Common output-related flags: --output-file, --output-format...
|
-- | Common output-related flags: --output-file, --output-format...
|
||||||
outputflags = [outputFormatFlag, outputFileFlag]
|
|
||||||
outputFormatFlag = flagReq ["output-format","O"] (\s opts -> Right $ setopt "output-format" s opts) "FMT" "select the output format. Supported formats:\ntxt, csv, html."
|
-- outputflags = [outputFormatFlag, outputFileFlag]
|
||||||
outputFileFlag = flagReq ["output-file","o"] (\s opts -> Right $ setopt "output-file" s opts) "FILE" "write output to FILE. A file extension matching one of the above formats selects that format."
|
|
||||||
|
outputFormatFlag :: [String] -> Flag RawOpts
|
||||||
|
outputFormatFlag fmts = flagReq
|
||||||
|
["output-format","O"] (\s opts -> Right $ setopt "output-format" s opts) "FMT"
|
||||||
|
("select the output format. Supported formats:\n" ++ intercalate ", " fmts ++ ".")
|
||||||
|
|
||||||
|
outputFileFlag :: Flag RawOpts
|
||||||
|
outputFileFlag = flagReq
|
||||||
|
["output-file","o"] (\s opts -> Right $ setopt "output-file" s opts) "FILE"
|
||||||
|
"write output to FILE. A file extension matching one of the above formats selects that format."
|
||||||
|
|
||||||
argsFlag :: FlagHelp -> Arg RawOpts
|
argsFlag :: FlagHelp -> Arg RawOpts
|
||||||
argsFlag desc = flagArg (\s opts -> Right $ setopt "args" s opts) desc
|
argsFlag desc = flagArg (\s opts -> Right $ setopt "args" s opts) desc
|
||||||
|
|||||||
@ -295,8 +295,9 @@ balancemode = hledgerCommandMode
|
|||||||
,flagNone ["invert"] (setboolopt "invert") "display all amounts with reversed sign"
|
,flagNone ["invert"] (setboolopt "invert") "display all amounts with reversed sign"
|
||||||
,flagNone ["transpose"] (setboolopt "transpose") "transpose rows and columns"
|
,flagNone ["transpose"] (setboolopt "transpose") "transpose rows and columns"
|
||||||
,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total"
|
,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total"
|
||||||
|
,outputFormatFlag ["txt","html","csv","json"]
|
||||||
|
,outputFileFlag
|
||||||
]
|
]
|
||||||
++ outputflags
|
|
||||||
)
|
)
|
||||||
[generalflagsgroup1]
|
[generalflagsgroup1]
|
||||||
hiddenflags
|
hiddenflags
|
||||||
|
|||||||
@ -39,7 +39,9 @@ printmode = hledgerCommandMode
|
|||||||
"show all amounts explicitly"
|
"show all amounts explicitly"
|
||||||
,flagNone ["new"] (setboolopt "new")
|
,flagNone ["new"] (setboolopt "new")
|
||||||
"show only newer-dated transactions added in each file since last run"
|
"show only newer-dated transactions added in each file since last run"
|
||||||
] ++ outputflags)
|
,outputFormatFlag ["txt","csv","json"]
|
||||||
|
,outputFileFlag
|
||||||
|
])
|
||||||
[generalflagsgroup1]
|
[generalflagsgroup1]
|
||||||
hiddenflags
|
hiddenflags
|
||||||
([], Just $ argsFlag "[QUERY]")
|
([], Just $ argsFlag "[QUERY]")
|
||||||
|
|||||||
@ -51,7 +51,9 @@ registermode = hledgerCommandMode
|
|||||||
#endif
|
#endif
|
||||||
++ " or $COLUMNS). -wN,M sets description width as well."
|
++ " or $COLUMNS). -wN,M sets description width as well."
|
||||||
)
|
)
|
||||||
] ++ outputflags)
|
,outputFormatFlag ["txt","csv","json"]
|
||||||
|
,outputFileFlag
|
||||||
|
])
|
||||||
[generalflagsgroup1]
|
[generalflagsgroup1]
|
||||||
hiddenflags
|
hiddenflags
|
||||||
([], Just $ argsFlag "[QUERY]")
|
([], Just $ argsFlag "[QUERY]")
|
||||||
|
|||||||
@ -108,7 +108,7 @@ compoundBalanceCommandMode CompoundBalanceCommandSpec{..} =
|
|||||||
,flagNone ["pretty-tables"] (setboolopt "pretty-tables") "use unicode when displaying tables"
|
,flagNone ["pretty-tables"] (setboolopt "pretty-tables") "use unicode when displaying tables"
|
||||||
,flagNone ["sort-amount","S"] (setboolopt "sort-amount") "sort by amount instead of account code/name"
|
,flagNone ["sort-amount","S"] (setboolopt "sort-amount") "sort by amount instead of account code/name"
|
||||||
,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total"
|
,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total"
|
||||||
,outputFormatFlag
|
,outputFormatFlag ["txt","html","csv","json"]
|
||||||
,outputFileFlag
|
,outputFileFlag
|
||||||
]
|
]
|
||||||
[generalflagsgroup1]
|
[generalflagsgroup1]
|
||||||
|
|||||||
@ -60,7 +60,7 @@ import Hledger.Utils
|
|||||||
|
|
||||||
-- | Standard error message for a bad output format specified with -O/-o.
|
-- | Standard error message for a bad output format specified with -O/-o.
|
||||||
unsupportedOutputFormatError :: String -> String
|
unsupportedOutputFormatError :: String -> String
|
||||||
unsupportedOutputFormatError fmt = "Sorry, output format \""++fmt++"\" is unrecognised or not yet implemented for this report."
|
unsupportedOutputFormatError fmt = "Sorry, output format \""++fmt++"\" is unrecognised or not yet implemented for this report or report mode."
|
||||||
|
|
||||||
-- | Parse the user's specified journal file(s) as a Journal, maybe apply some
|
-- | Parse the user's specified journal file(s) as a Journal, maybe apply some
|
||||||
-- transformations according to options, and run a hledger command with it.
|
-- transformations according to options, and run a hledger command with it.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user