packages feed

cmdargs 0.9 → 0.9.1

raw patch · 5 files changed

+29/−20 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

System/Console/CmdArgs/Explicit.hs view
@@ -10,21 +10,25 @@      As an example of a parser: -  > arguments :: Mode [(String,String)]-  > arguments = mode "explicit" [] "Explicit sample program" (flagArg (upd "file") "FILE")-  >     [flagOpt "world" ["hello","h"] (upd "world") "WHO" "World argument"-  >     ,flagReq ["greeting","g"] (upd "greeting") "MSG" "Greeting to give"-  >     ,flagHelpSimple (("help",""):)]-  >     where upd msg x v = Right $ (msg,x):v+    @+    arguments :: 'Mode' [(String,String)]+    arguments = 'mode' \"explicit\" [] \"Explicit sample program\" ('flagArg' (upd \"file\") \"FILE\")+        ['flagOpt' \"world\" [\"hello\",\"h\"] (upd \"world\") \"WHO\" \"World argument\"+        ,'flagReq' [\"greeting\",\"g\"] (upd \"greeting\") \"MSG\" \"Greeting to give\"+        ,'flagHelpSimple' ((\"help\",\"\"):)]+        where upd msg x v = Right $ (msg,x):v+    @      And this can be invoked by: -  > main = do-  >     xs <- processArgs arguments-  >     if ("help","") `elem` xs then-  >         print $ helpText HelpFormatDefault arguments-  >      else-  >         print xs+    @+    main = do+        xs <- 'processArgs' arguments+        if (\"help\",\"\") \`elem\` xs then+            print $ 'helpText' [] 'HelpFormatDefault' arguments+         else+            print xs+    @      /Groups/: The 'Group' structure allows flags/modes to be grouped for the purpose of     displaying help. When processing command lines, the group structure is ignored.
System/Console/CmdArgs/Explicit/Help.hs view
@@ -73,7 +73,8 @@ instance Show (Arg a) where     show = show . argType --- | Generate a help message from a mode.+-- | Generate a help message from a mode.  The first argument is a prefix,+--   which is prepended when not using 'HelpFormatBash' or 'HelpFormatZsh'. helpText :: [String] -> HelpFormat -> Mode a -> [Text] helpText pre HelpFormatDefault x = helpPrefix pre ++ helpTextDefault x helpText pre HelpFormatOne x = helpPrefix pre ++ helpTextOne x
System/Console/CmdArgs/Implicit.hs view
@@ -208,7 +208,8 @@ -- | Flag: \"I want several different flags to set this one field to different values.\" -- --   This annotation takes a type which is an enumeration, and provides multiple---   separate flags to set the field to each value.+--   separate flags to set the field to each value. The first element in the list+--   is used as the value of the field. -- -- > data State = On | Off deriving Data -- > data Mode = Mode {state :: State}
System/Console/CmdArgs/Implicit/Global.hs view
@@ -26,13 +26,16 @@ -- COLLAPSE THE FLAGS/MODES UPWARDS  collapse :: Prog_ -> Mode (CmdArgs Any)-collapse x | length ms == 1 = (head ms){modeNames=[progProgram x]}+collapse x | length ms == 1 = (snd $ head ms){modeNames=[progProgram x]}            | length auto > 1 = err "prog" "Multiple automatic modes"-           | otherwise = (head $ map zeroMode auto ++ map emptyMode ms)-                {modeNames=[progProgram x], modeGroupModes = toGroup ms, modeHelp = progHelp x}+           | otherwise = (head $ map zeroMode auto ++ map (emptyMode . snd) ms)+                {modeNames=[progProgram x], modeGroupModes=grouped, modeHelp=progHelp x}     where-        ms = map collapseMode $ progModes x-        auto = [m | (m,True) <- zip ms $ map modeDefault $ progModes x]+        grouped = Group (pick Nothing) [] [(g, pick $ Just g) | g <- nub $ mapMaybe (modeGroup . fst) ms]+        pick x = [m | (m_,m) <- ms, modeGroup m_ == x]++        ms = map (id &&& collapseMode) $ progModes x+        auto = [m | (m_,m) <- ms, modeDefault m_]   -- | A mode devoid of all it's contents
cmdargs.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.6 build-type:         Simple name:               cmdargs-version:            0.9+version:            0.9.1 license:            BSD3 license-file:       LICENSE category:           Console