diff --git a/hledger-lib/Hledger/Data/RawOptions.hs b/hledger-lib/Hledger/Data/RawOptions.hs index 17b52058e..ff63f023d 100644 --- a/hledger-lib/Hledger/Data/RawOptions.hs +++ b/hledger-lib/Hledger/Data/RawOptions.hs @@ -11,6 +11,7 @@ module Hledger.Data.RawOptions ( RawOpts, mkRawOpts, overRawOpts, + dropRawOpt, setopt, setboolopt, unsetboolopt, @@ -53,6 +54,9 @@ mkRawOpts = RawOpts overRawOpts :: ([(String,String)] -> [(String,String)]) -> RawOpts -> RawOpts overRawOpts f = RawOpts . f . unRawOpts +dropRawOpt :: String -> RawOpts -> RawOpts +dropRawOpt a = overRawOpts $ filter (not.(==a).fst) + setopt :: String -> String -> RawOpts -> RawOpts setopt name val = overRawOpts (++ [(name, val)]) diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 057264c07..8efbf0edc 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -58,6 +58,7 @@ module Hledger.Cli.CliOptions ( getHledgerCliOpts, getHledgerCliOpts', rawOptsToCliOpts, + cliOptsDropArgs, outputFormats, defaultOutputFormat, CommandHelpStr, @@ -641,6 +642,10 @@ rawOptsToCliOpts rawopts = do ,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 -- the current command line using the given hledger-style cmdargs mode, -- and returns a CliOpts. Or, with --help or -h present, it prints