mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-28 21:02:04 +03:00
allow command-line options to be anywhere when negativepatternchar is something other than -
This commit is contained in:
parent
5fcab59414
commit
c404ae45d6
@ -3,12 +3,13 @@ where
|
|||||||
import System
|
import System
|
||||||
import System.Console.GetOpt
|
import System.Console.GetOpt
|
||||||
import System.Directory
|
import System.Directory
|
||||||
|
import Ledger.RawLedger (negativepatternchar)
|
||||||
|
|
||||||
usagehdr = "Usage: hledger [OPTIONS] "++commands++" [ACCTPATTERNS] [-- DESCPATTERNS]\nOptions:"
|
usagehdr = "Usage: hledger [OPTIONS] "++commands++" [ACCTPATTERNS] [-- DESCPATTERNS]\nOptions:"
|
||||||
commands = "register|balance|print"
|
commands = "register|balance|print"
|
||||||
defaultfile = "~/.ledger"
|
defaultfile = "~/.ledger"
|
||||||
fileenvvar = "LEDGER"
|
fileenvvar = "LEDGER"
|
||||||
|
optionorder = if negativepatternchar=='-' then RequireOrder else Permute
|
||||||
|
|
||||||
-- | Command-line options we accept.
|
-- | Command-line options we accept.
|
||||||
options :: [OptDescr Opt]
|
options :: [OptDescr Opt]
|
||||||
@ -40,7 +41,7 @@ version = "hledger version 0.1 alpha\n"
|
|||||||
parseArguments :: IO ([Opt], String, [String])
|
parseArguments :: IO ([Opt], String, [String])
|
||||||
parseArguments = do
|
parseArguments = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
case (getOpt RequireOrder options args) of
|
case (getOpt optionorder options args) of
|
||||||
(opts,cmd:args,[]) -> return (opts, cmd, args)
|
(opts,cmd:args,[]) -> return (opts, cmd, args)
|
||||||
(opts,[],[]) -> return ([Help], [], [])
|
(opts,[],[]) -> return ([Help], [], [])
|
||||||
(_,_,errs) -> ioError (userError (concat errs ++ usage))
|
(_,_,errs) -> ioError (userError (concat errs ++ usage))
|
||||||
|
Loading…
Reference in New Issue
Block a user