core-program 0.2.4.1 → 0.2.4.2
raw patch · 3 files changed
+27/−10 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Core.System.Pretty: fillCat :: () => [Doc ann] -> Doc ann
Files
- core-program.cabal +2/−2
- lib/Core/Program/Arguments.hs +24/−8
- lib/Core/System/Pretty.hs +1/−0
core-program.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 7e0eff3f9f82d279f562a769a41334fdf5600e0bc7c99d4fd9a09b3ad851a872+-- hash: 803485247c31b54276f04b6bbfa4aa2c9ef78802a0c00f9dc906ad3c3b5742a1 name: core-program-version: 0.2.4.1+version: 0.2.4.2 synopsis: Opinionated Haskell Interoperability description: A library to help build command-line programs, both tools and longer-running daemons.
lib/Core/Program/Arguments.hs view
@@ -494,8 +494,9 @@ globalOptions = extractGlobalOptions commands modes = extractValidModes commands in do- (possibles,first,remainingArgs) <- splitCommandLine argv+ (possibles,argv') <- splitCommandLine1 argv params1 <- extractor Nothing globalOptions possibles+ (first,remainingArgs) <- splitCommandLine2 argv' (mode,localOptions) <- parseIndicatedCommand modes first params2 <- extractor (Just mode) localOptions remainingArgs return (Parameters (Just mode) ((<>) params1 params2) emptyMap)@@ -632,17 +633,32 @@ k (Command longname _ options) modes = insertKeyValue longname options modes k _ modes = modes -splitCommandLine :: [String] -> Either InvalidCommandLine ([String], String, [String])-splitCommandLine args =+{-|+Break the command-line apart in two steps. The first peels off the global+options, the second below looks to see if there is a command (of fails) and+if so, whether it has any parameters.++We do it this way so that `parseCommandLine` can pas the global options to+`extractor` and thence `parsePossibleOptions` to catch --version and+--help.+-}+splitCommandLine1 :: [String] -> Either InvalidCommandLine ([String], [String])+splitCommandLine1 args = let (possibles,remainder) = List.span isOption args- x = List.uncons remainder in+ if null possibles && null remainder+ then Left NoCommandFound+ else Right (possibles,remainder)++splitCommandLine2 :: [String] -> Either InvalidCommandLine (String, [String])+splitCommandLine2 argv' =+ let+ x = List.uncons argv'+ in case x of- Just (mode,remainingArgs) -> Right (possibles,mode,remainingArgs)- Nothing -> if (List.elem "--help" possibles)- then Left (HelpRequest Nothing)- else Left NoCommandFound+ Just (mode,remainingArgs) -> Right (mode,remainingArgs)+ Nothing -> Left NoCommandFound -- -- Environment variable handling
lib/Core/System/Pretty.hs view
@@ -27,6 +27,7 @@ , sep , hsep , vsep+ , fillCat , fillSep , flatAlt , hcat