lib: add dropRawOpt, cliOptsDropArgs
This commit is contained in:
parent
54e7a178b3
commit
adef1a8416
@ -11,6 +11,7 @@ module Hledger.Data.RawOptions (
|
|||||||
RawOpts,
|
RawOpts,
|
||||||
mkRawOpts,
|
mkRawOpts,
|
||||||
overRawOpts,
|
overRawOpts,
|
||||||
|
dropRawOpt,
|
||||||
setopt,
|
setopt,
|
||||||
setboolopt,
|
setboolopt,
|
||||||
unsetboolopt,
|
unsetboolopt,
|
||||||
@ -53,6 +54,9 @@ mkRawOpts = RawOpts
|
|||||||
overRawOpts :: ([(String,String)] -> [(String,String)]) -> RawOpts -> RawOpts
|
overRawOpts :: ([(String,String)] -> [(String,String)]) -> RawOpts -> RawOpts
|
||||||
overRawOpts f = RawOpts . f . unRawOpts
|
overRawOpts f = RawOpts . f . unRawOpts
|
||||||
|
|
||||||
|
dropRawOpt :: String -> RawOpts -> RawOpts
|
||||||
|
dropRawOpt a = overRawOpts $ filter (not.(==a).fst)
|
||||||
|
|
||||||
setopt :: String -> String -> RawOpts -> RawOpts
|
setopt :: String -> String -> RawOpts -> RawOpts
|
||||||
setopt name val = overRawOpts (++ [(name, val)])
|
setopt name val = overRawOpts (++ [(name, val)])
|
||||||
|
|
||||||
|
|||||||
@ -58,6 +58,7 @@ module Hledger.Cli.CliOptions (
|
|||||||
getHledgerCliOpts,
|
getHledgerCliOpts,
|
||||||
getHledgerCliOpts',
|
getHledgerCliOpts',
|
||||||
rawOptsToCliOpts,
|
rawOptsToCliOpts,
|
||||||
|
cliOptsDropArgs,
|
||||||
outputFormats,
|
outputFormats,
|
||||||
defaultOutputFormat,
|
defaultOutputFormat,
|
||||||
CommandHelpStr,
|
CommandHelpStr,
|
||||||
@ -641,6 +642,10 @@ rawOptsToCliOpts rawopts = do
|
|||||||
,available_width_ = availablewidth
|
,available_width_ = availablewidth
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- | Drop the arguments ("args") from this CliOpts' rawopts field.
|
||||||
|
cliOptsDropArgs :: CliOpts -> CliOpts
|
||||||
|
cliOptsDropArgs copts@CliOpts{rawopts_} = copts{rawopts_ = dropRawOpt "args" rawopts_}
|
||||||
|
|
||||||
-- | A helper for addon commands: this parses options and arguments from
|
-- | A helper for addon commands: this parses options and arguments from
|
||||||
-- the current command line using the given hledger-style cmdargs mode,
|
-- the current command line using the given hledger-style cmdargs mode,
|
||||||
-- and returns a CliOpts. Or, with --help or -h present, it prints
|
-- and returns a CliOpts. Or, with --help or -h present, it prints
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user