From c404ae45d6ad8a1170066c67c49a3a082862b68f Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 15 Oct 2008 17:06:40 +0000 Subject: [PATCH] allow command-line options to be anywhere when negativepatternchar is something other than - --- Options.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Options.hs b/Options.hs index 79c1da0f6..31d055749 100644 --- a/Options.hs +++ b/Options.hs @@ -3,12 +3,13 @@ where import System import System.Console.GetOpt import System.Directory - +import Ledger.RawLedger (negativepatternchar) usagehdr = "Usage: hledger [OPTIONS] "++commands++" [ACCTPATTERNS] [-- DESCPATTERNS]\nOptions:" commands = "register|balance|print" defaultfile = "~/.ledger" fileenvvar = "LEDGER" +optionorder = if negativepatternchar=='-' then RequireOrder else Permute -- | Command-line options we accept. options :: [OptDescr Opt] @@ -40,7 +41,7 @@ version = "hledger version 0.1 alpha\n" parseArguments :: IO ([Opt], String, [String]) parseArguments = do args <- getArgs - case (getOpt RequireOrder options args) of + case (getOpt optionorder options args) of (opts,cmd:args,[]) -> return (opts, cmd, args) (opts,[],[]) -> return ([Help], [], []) (_,_,errs) -> ioError (userError (concat errs ++ usage))