cmdargs 0.10.13 → 0.10.14
raw patch · 6 files changed
+281/−312 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- System.Console.CmdArgs.Annotate: instance Exception ExceptionInt
- System.Console.CmdArgs.Annotate: instance Functor Capture
- System.Console.CmdArgs.Annotate: instance Show ExceptionInt
- System.Console.CmdArgs.Annotate: instance Show ann => Show (Capture ann)
- System.Console.CmdArgs.Annotate: instance Typeable Annotate
- System.Console.CmdArgs.Annotate: instance Typeable ExceptionInt
- System.Console.CmdArgs.Default: instance (Default a1, Default a2) => Default (a1, a2)
- System.Console.CmdArgs.Default: instance (Default a1, Default a2, Default a3) => Default (a1, a2, a3)
- System.Console.CmdArgs.Default: instance (Default a1, Default a2, Default a3, Default a4) => Default (a1, a2, a3, a4)
- System.Console.CmdArgs.Default: instance (Default a1, Default a2, Default a3, Default a4, Default a5) => Default (a1, a2, a3, a4, a5)
- System.Console.CmdArgs.Default: instance (Default a1, Default a2, Default a3, Default a4, Default a5, Default a6) => Default (a1, a2, a3, a4, a5, a6)
- System.Console.CmdArgs.Default: instance (Default a1, Default a2, Default a3, Default a4, Default a5, Default a6, Default a7) => Default (a1, a2, a3, a4, a5, a6, a7)
- System.Console.CmdArgs.Default: instance (Default a1, Default a2, Default a3, Default a4, Default a5, Default a6, Default a7, Default a8) => Default (a1, a2, a3, a4, a5, a6, a7, a8)
- System.Console.CmdArgs.Default: instance (Default a1, Default a2, Default a3, Default a4, Default a5, Default a6, Default a7, Default a8, Default a9) => Default (a1, a2, a3, a4, a5, a6, a7, a8, a9)
- System.Console.CmdArgs.Default: instance (Default a1, Default a2, Default a3, Default a4, Default a5, Default a6, Default a7, Default a8, Default a9, Default a10) => Default (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
- System.Console.CmdArgs.Default: instance Default ()
- System.Console.CmdArgs.Default: instance Default (Maybe a)
- System.Console.CmdArgs.Default: instance Default Bool
- System.Console.CmdArgs.Default: instance Default Double
- System.Console.CmdArgs.Default: instance Default Float
- System.Console.CmdArgs.Default: instance Default Int
- System.Console.CmdArgs.Default: instance Default Int16
- System.Console.CmdArgs.Default: instance Default Int32
- System.Console.CmdArgs.Default: instance Default Int64
- System.Console.CmdArgs.Default: instance Default Int8
- System.Console.CmdArgs.Default: instance Default Integer
- System.Console.CmdArgs.Default: instance Default Word
- System.Console.CmdArgs.Default: instance Default Word16
- System.Console.CmdArgs.Default: instance Default Word32
- System.Console.CmdArgs.Default: instance Default Word64
- System.Console.CmdArgs.Default: instance Default Word8
- System.Console.CmdArgs.Default: instance Default [a]
- System.Console.CmdArgs.Explicit: argRequire :: Arg a -> Bool
- System.Console.CmdArgs.Explicit: argType :: Arg a -> FlagHelp
- System.Console.CmdArgs.Explicit: argValue :: Arg a -> Update a
- System.Console.CmdArgs.Explicit: flagHelp :: Flag a -> Help
- System.Console.CmdArgs.Explicit: flagInfo :: Flag a -> FlagInfo
- System.Console.CmdArgs.Explicit: flagNames :: Flag a -> [Name]
- System.Console.CmdArgs.Explicit: flagType :: Flag a -> FlagHelp
- System.Console.CmdArgs.Explicit: flagValue :: Flag a -> Update a
- System.Console.CmdArgs.Explicit: groupHidden :: Group a -> [a]
- System.Console.CmdArgs.Explicit: groupNamed :: Group a -> [(Help, [a])]
- System.Console.CmdArgs.Explicit: groupUnnamed :: Group a -> [a]
- System.Console.CmdArgs.Explicit: modeArgs :: Mode a -> ([Arg a], Maybe (Arg a))
- System.Console.CmdArgs.Explicit: modeCheck :: Mode a -> a -> Either String a
- System.Console.CmdArgs.Explicit: modeExpandAt :: Mode a -> Bool
- System.Console.CmdArgs.Explicit: modeGroupFlags :: Mode a -> Group (Flag a)
- System.Console.CmdArgs.Explicit: modeGroupModes :: Mode a -> Group (Mode a)
- System.Console.CmdArgs.Explicit: modeHelp :: Mode a -> Help
- System.Console.CmdArgs.Explicit: modeHelpSuffix :: Mode a -> [String]
- System.Console.CmdArgs.Explicit: modeNames :: Mode a -> [Name]
- System.Console.CmdArgs.Explicit: modeReform :: Mode a -> a -> Maybe [String]
- System.Console.CmdArgs.Explicit: modeValue :: Mode a -> a
- System.Console.CmdArgs.Helper: instance (Packer a, Packer b) => Packer (Either a b)
- System.Console.CmdArgs.Helper: instance (Packer a, Packer b) => Packer (a -> b)
- System.Console.CmdArgs.Helper: instance (Packer a, Packer b) => Packer (a, b)
- System.Console.CmdArgs.Helper: instance Packer Bool
- System.Console.CmdArgs.Helper: instance Packer Char
- System.Console.CmdArgs.Helper: instance Packer FlagInfo
- System.Console.CmdArgs.Helper: instance Packer Int
- System.Console.CmdArgs.Helper: instance Packer Value
- System.Console.CmdArgs.Helper: instance Packer a => Packer (Arg a)
- System.Console.CmdArgs.Helper: instance Packer a => Packer (Flag a)
- System.Console.CmdArgs.Helper: instance Packer a => Packer (Group a)
- System.Console.CmdArgs.Helper: instance Packer a => Packer (Maybe a)
- System.Console.CmdArgs.Helper: instance Packer a => Packer (Mode a)
- System.Console.CmdArgs.Helper: instance Packer a => Packer [a]
- System.Console.CmdArgs.Helper: instance Read (NoShow a)
- System.Console.CmdArgs.Helper: instance Read Pack
- System.Console.CmdArgs.Helper: instance Show (NoShow a)
- System.Console.CmdArgs.Helper: instance Show Pack
- System.Console.CmdArgs.Implicit: cmdArgsHelp :: CmdArgs a -> Maybe String
- System.Console.CmdArgs.Implicit: cmdArgsPrivate :: CmdArgs a -> CmdArgsPrivate
- System.Console.CmdArgs.Implicit: cmdArgsValue :: CmdArgs a -> a
- System.Console.CmdArgs.Implicit: cmdArgsVerbosity :: CmdArgs a -> Maybe Verbosity
- System.Console.CmdArgs.Implicit: cmdArgsVersion :: CmdArgs a -> Maybe String
- System.Console.CmdArgs.Text: instance Default TextFormat
- System.Console.CmdArgs.Text: instance Eq TextFormat
- System.Console.CmdArgs.Text: instance Ord TextFormat
- System.Console.CmdArgs.Text: instance Read TextFormat
- System.Console.CmdArgs.Text: instance Show Text
- System.Console.CmdArgs.Text: instance Show TextFormat
- System.Console.CmdArgs.Verbosity: instance Bounded Verbosity
- System.Console.CmdArgs.Verbosity: instance Data Verbosity
- System.Console.CmdArgs.Verbosity: instance Enum Verbosity
- System.Console.CmdArgs.Verbosity: instance Eq Verbosity
- System.Console.CmdArgs.Verbosity: instance Ord Verbosity
- System.Console.CmdArgs.Verbosity: instance Read Verbosity
- System.Console.CmdArgs.Verbosity: instance Show Verbosity
- System.Console.CmdArgs.Verbosity: instance Typeable Verbosity
+ System.Console.CmdArgs.Annotate: instance GHC.Base.Functor System.Console.CmdArgs.Annotate.Capture
+ System.Console.CmdArgs.Annotate: instance GHC.Exception.Exception System.Console.CmdArgs.Annotate.ExceptionInt
+ System.Console.CmdArgs.Annotate: instance GHC.Show.Show System.Console.CmdArgs.Annotate.ExceptionInt
+ System.Console.CmdArgs.Annotate: instance GHC.Show.Show ann => GHC.Show.Show (System.Console.CmdArgs.Annotate.Capture ann)
+ System.Console.CmdArgs.Default: instance (System.Console.CmdArgs.Default.Default a1, System.Console.CmdArgs.Default.Default a2) => System.Console.CmdArgs.Default.Default (a1, a2)
+ System.Console.CmdArgs.Default: instance (System.Console.CmdArgs.Default.Default a1, System.Console.CmdArgs.Default.Default a2, System.Console.CmdArgs.Default.Default a3) => System.Console.CmdArgs.Default.Default (a1, a2, a3)
+ System.Console.CmdArgs.Default: instance (System.Console.CmdArgs.Default.Default a1, System.Console.CmdArgs.Default.Default a2, System.Console.CmdArgs.Default.Default a3, System.Console.CmdArgs.Default.Default a4) => System.Console.CmdArgs.Default.Default (a1, a2, a3, a4)
+ System.Console.CmdArgs.Default: instance (System.Console.CmdArgs.Default.Default a1, System.Console.CmdArgs.Default.Default a2, System.Console.CmdArgs.Default.Default a3, System.Console.CmdArgs.Default.Default a4, System.Console.CmdArgs.Default.Default a5) => System.Console.CmdArgs.Default.Default (a1, a2, a3, a4, a5)
+ System.Console.CmdArgs.Default: instance (System.Console.CmdArgs.Default.Default a1, System.Console.CmdArgs.Default.Default a2, System.Console.CmdArgs.Default.Default a3, System.Console.CmdArgs.Default.Default a4, System.Console.CmdArgs.Default.Default a5, System.Console.CmdArgs.Default.Default a6) => System.Console.CmdArgs.Default.Default (a1, a2, a3, a4, a5, a6)
+ System.Console.CmdArgs.Default: instance (System.Console.CmdArgs.Default.Default a1, System.Console.CmdArgs.Default.Default a2, System.Console.CmdArgs.Default.Default a3, System.Console.CmdArgs.Default.Default a4, System.Console.CmdArgs.Default.Default a5, System.Console.CmdArgs.Default.Default a6, System.Console.CmdArgs.Default.Default a7) => System.Console.CmdArgs.Default.Default (a1, a2, a3, a4, a5, a6, a7)
+ System.Console.CmdArgs.Default: instance (System.Console.CmdArgs.Default.Default a1, System.Console.CmdArgs.Default.Default a2, System.Console.CmdArgs.Default.Default a3, System.Console.CmdArgs.Default.Default a4, System.Console.CmdArgs.Default.Default a5, System.Console.CmdArgs.Default.Default a6, System.Console.CmdArgs.Default.Default a7, System.Console.CmdArgs.Default.Default a8) => System.Console.CmdArgs.Default.Default (a1, a2, a3, a4, a5, a6, a7, a8)
+ System.Console.CmdArgs.Default: instance (System.Console.CmdArgs.Default.Default a1, System.Console.CmdArgs.Default.Default a2, System.Console.CmdArgs.Default.Default a3, System.Console.CmdArgs.Default.Default a4, System.Console.CmdArgs.Default.Default a5, System.Console.CmdArgs.Default.Default a6, System.Console.CmdArgs.Default.Default a7, System.Console.CmdArgs.Default.Default a8, System.Console.CmdArgs.Default.Default a9) => System.Console.CmdArgs.Default.Default (a1, a2, a3, a4, a5, a6, a7, a8, a9)
+ System.Console.CmdArgs.Default: instance (System.Console.CmdArgs.Default.Default a1, System.Console.CmdArgs.Default.Default a2, System.Console.CmdArgs.Default.Default a3, System.Console.CmdArgs.Default.Default a4, System.Console.CmdArgs.Default.Default a5, System.Console.CmdArgs.Default.Default a6, System.Console.CmdArgs.Default.Default a7, System.Console.CmdArgs.Default.Default a8, System.Console.CmdArgs.Default.Default a9, System.Console.CmdArgs.Default.Default a10) => System.Console.CmdArgs.Default.Default (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default ()
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default (GHC.Base.Maybe a)
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Int.Int16
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Int.Int32
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Int.Int64
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Int.Int8
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Integer.Type.Integer
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Types.Bool
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Types.Double
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Types.Float
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Types.Int
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Types.Word
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Word.Word16
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Word.Word32
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Word.Word64
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default GHC.Word.Word8
+ System.Console.CmdArgs.Default: instance System.Console.CmdArgs.Default.Default [a]
+ System.Console.CmdArgs.Explicit: [argRequire] :: Arg a -> Bool
+ System.Console.CmdArgs.Explicit: [argType] :: Arg a -> FlagHelp
+ System.Console.CmdArgs.Explicit: [argValue] :: Arg a -> Update a
+ System.Console.CmdArgs.Explicit: [flagHelp] :: Flag a -> Help
+ System.Console.CmdArgs.Explicit: [flagInfo] :: Flag a -> FlagInfo
+ System.Console.CmdArgs.Explicit: [flagNames] :: Flag a -> [Name]
+ System.Console.CmdArgs.Explicit: [flagType] :: Flag a -> FlagHelp
+ System.Console.CmdArgs.Explicit: [flagValue] :: Flag a -> Update a
+ System.Console.CmdArgs.Explicit: [groupHidden] :: Group a -> [a]
+ System.Console.CmdArgs.Explicit: [groupNamed] :: Group a -> [(Help, [a])]
+ System.Console.CmdArgs.Explicit: [groupUnnamed] :: Group a -> [a]
+ System.Console.CmdArgs.Explicit: [modeArgs] :: Mode a -> ([Arg a], Maybe (Arg a))
+ System.Console.CmdArgs.Explicit: [modeCheck] :: Mode a -> a -> Either String a
+ System.Console.CmdArgs.Explicit: [modeExpandAt] :: Mode a -> Bool
+ System.Console.CmdArgs.Explicit: [modeGroupFlags] :: Mode a -> Group (Flag a)
+ System.Console.CmdArgs.Explicit: [modeGroupModes] :: Mode a -> Group (Mode a)
+ System.Console.CmdArgs.Explicit: [modeHelpSuffix] :: Mode a -> [String]
+ System.Console.CmdArgs.Explicit: [modeHelp] :: Mode a -> Help
+ System.Console.CmdArgs.Explicit: [modeNames] :: Mode a -> [Name]
+ System.Console.CmdArgs.Explicit: [modeReform] :: Mode a -> a -> Maybe [String]
+ System.Console.CmdArgs.Explicit: [modeValue] :: Mode a -> a
+ System.Console.CmdArgs.Helper: instance (System.Console.CmdArgs.Helper.Packer a, System.Console.CmdArgs.Helper.Packer b) => System.Console.CmdArgs.Helper.Packer (Data.Either.Either a b)
+ System.Console.CmdArgs.Helper: instance (System.Console.CmdArgs.Helper.Packer a, System.Console.CmdArgs.Helper.Packer b) => System.Console.CmdArgs.Helper.Packer (a -> b)
+ System.Console.CmdArgs.Helper: instance (System.Console.CmdArgs.Helper.Packer a, System.Console.CmdArgs.Helper.Packer b) => System.Console.CmdArgs.Helper.Packer (a, b)
+ System.Console.CmdArgs.Helper: instance GHC.Read.Read (System.Console.CmdArgs.Helper.NoShow a)
+ System.Console.CmdArgs.Helper: instance GHC.Read.Read System.Console.CmdArgs.Helper.Pack
+ System.Console.CmdArgs.Helper: instance GHC.Show.Show (System.Console.CmdArgs.Helper.NoShow a)
+ System.Console.CmdArgs.Helper: instance GHC.Show.Show System.Console.CmdArgs.Helper.Pack
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer GHC.Types.Bool
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer GHC.Types.Char
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer GHC.Types.Int
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer System.Console.CmdArgs.Explicit.Type.FlagInfo
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer System.Console.CmdArgs.Helper.Value
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer a => System.Console.CmdArgs.Helper.Packer (GHC.Base.Maybe a)
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer a => System.Console.CmdArgs.Helper.Packer (System.Console.CmdArgs.Explicit.Type.Arg a)
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer a => System.Console.CmdArgs.Helper.Packer (System.Console.CmdArgs.Explicit.Type.Flag a)
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer a => System.Console.CmdArgs.Helper.Packer (System.Console.CmdArgs.Explicit.Type.Group a)
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer a => System.Console.CmdArgs.Helper.Packer (System.Console.CmdArgs.Explicit.Type.Mode a)
+ System.Console.CmdArgs.Helper: instance System.Console.CmdArgs.Helper.Packer a => System.Console.CmdArgs.Helper.Packer [a]
+ System.Console.CmdArgs.Implicit: [cmdArgsHelp] :: CmdArgs a -> Maybe String
+ System.Console.CmdArgs.Implicit: [cmdArgsPrivate] :: CmdArgs a -> CmdArgsPrivate
+ System.Console.CmdArgs.Implicit: [cmdArgsValue] :: CmdArgs a -> a
+ System.Console.CmdArgs.Implicit: [cmdArgsVerbosity] :: CmdArgs a -> Maybe Verbosity
+ System.Console.CmdArgs.Implicit: [cmdArgsVersion] :: CmdArgs a -> Maybe String
+ System.Console.CmdArgs.Text: instance GHC.Classes.Eq System.Console.CmdArgs.Text.TextFormat
+ System.Console.CmdArgs.Text: instance GHC.Classes.Ord System.Console.CmdArgs.Text.TextFormat
+ System.Console.CmdArgs.Text: instance GHC.Read.Read System.Console.CmdArgs.Text.TextFormat
+ System.Console.CmdArgs.Text: instance GHC.Show.Show System.Console.CmdArgs.Text.Text
+ System.Console.CmdArgs.Text: instance GHC.Show.Show System.Console.CmdArgs.Text.TextFormat
+ System.Console.CmdArgs.Text: instance System.Console.CmdArgs.Default.Default System.Console.CmdArgs.Text.TextFormat
+ System.Console.CmdArgs.Verbosity: instance Data.Data.Data System.Console.CmdArgs.Verbosity.Verbosity
+ System.Console.CmdArgs.Verbosity: instance GHC.Classes.Eq System.Console.CmdArgs.Verbosity.Verbosity
+ System.Console.CmdArgs.Verbosity: instance GHC.Classes.Ord System.Console.CmdArgs.Verbosity.Verbosity
+ System.Console.CmdArgs.Verbosity: instance GHC.Enum.Bounded System.Console.CmdArgs.Verbosity.Verbosity
+ System.Console.CmdArgs.Verbosity: instance GHC.Enum.Enum System.Console.CmdArgs.Verbosity.Verbosity
+ System.Console.CmdArgs.Verbosity: instance GHC.Read.Read System.Console.CmdArgs.Verbosity.Verbosity
+ System.Console.CmdArgs.Verbosity: instance GHC.Show.Show System.Console.CmdArgs.Verbosity.Verbosity
- System.Console.CmdArgs.Explicit: remapUpdate :: Functor f => t -> (t2 -> (t1, a -> b)) -> (t3 -> t1 -> f a) -> t3 -> t2 -> f b
+ System.Console.CmdArgs.Explicit: remapUpdate :: Functor f => t -> (t1 -> (t2, a -> b)) -> (t3 -> t2 -> f a) -> t3 -> t1 -> f b
Files
- CHANGES.txt +4/−0
- LICENSE +1/−1
- README.md +258/−299
- System/Console/CmdArgs/Test/Implicit/Tests.hs +2/−2
- System/Console/CmdArgs/Text.hs +11/−5
- cmdargs.cabal +5/−5
CHANGES.txt view
@@ -1,5 +1,9 @@ Changelog for CmdArgs +0.10.14+ #39, ensure correct line breaks in HTML help output+ #18, preserve manual \n in help messages+ #25, reformat the README 0.10.13 #24, support Ratio in some places 0.10.12
LICENSE view
@@ -1,4 +1,4 @@-Copyright Neil Mitchell 2009-2015.+Copyright Neil Mitchell 2009-2016. All rights reserved. Redistribution and use in source and binary forms, with or without
README.md view
@@ -1,67 +1,54 @@ # CmdArgs: Easy Command Line Processing [](https://hackage.haskell.org/package/cmdargs) [](https://travis-ci.org/ndmitchell/cmdargs) -<p>- CmdArgs is a Haskell library for defining command line parsers. The two features that make it a better choice than the standard <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/System-Console-GetOpt.html">getopt library</a> are:-</p>-<ol>- <li>It's very concise to use. The HLint command line handling is three times shorter with CmdArgs.</li>- <li>It supports programs with multiple modes, such as <a href="http://darcs.net">darcs</a> or <a href="http://haskell.org/cabal/">Cabal</a>.</li>-</ol>-<p>- A very simple example of a command line processor is:-</p>-<pre>-data Sample = Sample {hello :: String} deriving (Show, Data, Typeable)+CmdArgs is a Haskell library for defining command line parsers. The two features that make it a better choice than the standard [getopt library](http://haskell.org/ghc/docs/latest/html/libraries/base/System-Console-GetOpt.html) are: -sample = Sample{hello = def &= help "World argument" &= opt "world"}- &= summary "Sample v1"+* It's very concise to use. The HLint command line handling is three times shorter with CmdArgs.+* It supports programs with multiple modes, such as [darcs](http://darcs.net) or [Cabal](http://haskell.org/cabal/). -main = print =<< cmdArgs sample-</pre>-<p>- Despite being very concise, this processor is already fairly well featured:-</p>-<pre>-$ runhaskell Sample.hs --hello=world-Sample {hello = "world"}+A very simple example of a command line processor is: -$ runhaskell Sample.hs --help-Sample v1, (C) Neil Mitchell 2009+ data Sample = Sample {hello :: String} deriving (Show, Data, Typeable)+ + sample = Sample{hello = def &= help "World argument" &= opt "world"}+ &= summary "Sample v1"+ + main = print =<< cmdArgs sample -sample [FLAG]+Despite being very concise, this processor is already fairly well featured: - -? --help[=FORMAT] Show usage information (optional format)- -V --version Show version information- -v --verbose Higher verbosity- -q --quiet Lower verbosity- -h --hello=VALUE World argument (default=world)-</pre>+ $ runhaskell Sample.hs --hello=world+ Sample {hello = "world"}+ + $ runhaskell Sample.hs --help+ Sample v1, (C) Neil Mitchell 2009+ + sample [FLAG]+ + -? --help[=FORMAT] Show usage information (optional format)+ -V --version Show version information+ -v --verbose Higher verbosity+ -q --quiet Lower verbosity+ -h --hello=VALUE World argument (default=world) -<h2>User Manual</h2>+## User Manual -<p>- The rest of this document explains how to write the "hello world" of command line processors, then how to extend it with features into a complex command line processor. Finally this document gives three samples, which the <tt>cmdargs</tt> program can run. The three samples are:-</p>-<ol>- <li><tt>hlint</tt> - the <a href="http://community.haskell.org/~ndm/hlint/">HLint</a> program.</li>- <li><tt>diffy</tt> - a program to compare the differences between directories.</li>- <li><tt>maker</tt> - a make style program.</li>-</ol>-<p>- For each example you are encouraged to look at it's source (see the <a href="http://community.haskell.org/~ndm/darcs/hlint">darcs repo</a>, or the bottom of this document) and run it (try <tt>cmdargs hlint --help</tt>). The HLint program is fairly standard in terms of it's argument processing, and previously used the <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/System-Console-GetOpt.html">System.Console.GetOpt</a> library. Using GetOpt required 90 lines and a reasonable amount of duplication. Using CmdArgs the code requires 30 lines, and the logic is much simpler.-</p>-<h3>Acknowledgements</h3>-<p>- Thanks to Kevin Quick for substantial patches, and additional code contributions from Sebastian Fischer and Daniel Schoepe.-</p>+The rest of this document explains how to write the "hello world" of command line processors, then how to extend it with features into a complex command line processor. Finally this document gives three samples, which the `cmdargs` program can run. The three samples are: +* `hlint` - the [HLint](https://github.com/ndmitchell/hlint#readme) program.+* `diffy` - a program to compare the differences between directories.+* `maker` - a make style program. -<h2>Hello World Example</h2>-<p>- The following code defines a complete command line argument processor:-</p>+For each example you are encouraged to look at it's source (in the [repo](https://github.com/ndmitchell/cmdargs/tree/master/System/Console/CmdArgs/Test/Implicit)) and run it (try `cmdargs hlint --help`). The HLint program is fairly standard in terms of it's argument processing, and previously used the [System.Console.GetOpt](http://haskell.org/ghc/docs/latest/html/libraries/base/System-Console-GetOpt.html) library. Using GetOpt required 90 lines and a reasonable amount of duplication. Using CmdArgs the code requires 30 lines, and the logic is much simpler. +**Acknowledgements** Thanks to Kevin Quick for substantial patches, and additional code contributions from Sebastian Fischer and Daniel Schoepe.+++## Hello World Example++The following code defines a complete command line argument processor:+ {-# LANGUAGE DeriveDataTypeable #-}+ {-# OPTIONS_GHC -fno-cse #-} module Sample where import System.Console.CmdArgs @@ -72,65 +59,51 @@ main = print =<< cmdArgs sample -<p>- To use the CmdArgs library there are three steps:-</p>-<ol>- <li>Define a record data type (<tt>Sample</tt>) that contains a field for each argument. This type needs to have instances for <tt>Show</tt>, <tt>Data</tt> and <tt>Typeable</tt>.</li>- <li>Give a value of that type (<tt>sample</tt>) with default values (<tt>def</tt> is a default value of any type, but I could also have written <tt>""</tt>). This value is turned into a command line by calling the <tt>cmdArgs</tt> function.</li>-</ol>-<p>- Now we have a reasonably functional command line argument processor. Some sample interactions are:-</p>-<pre>-$ runhaskell Sample.hs --hello=world-Sample {hello = "world"}+To use the CmdArgs library there are three steps: -$ runhaskell Sample.hs --version-The sample program+* Define a record data type (`Sample`) that contains a field for each argument. This type needs to have instances for `Show`, `Data` and `Typeable`.+* Give a value of that type (`sample`) with default values (`def` is a default value of any type, but I could also have written `""`). This value is turned into a command line by calling the `cmdArgs` function.+* To ensure GHC evalutes attributes the right number of times we disable the CSE optimisation on this module. -$ runhaskell Sample.hs --help-The sample program+Now we have a reasonably functional command line argument processor. Some sample interactions are: -sample [OPTIONS]+ $ runhaskell Sample.hs --hello=world+ Sample {hello = "world"}+ + $ runhaskell Sample.hs --version+ The sample program+ + $ runhaskell Sample.hs --help+ The sample program+ + sample [OPTIONS]+ + -? --help Display help message+ -V --version Print version information+ -h --hello=ITEM - -? --help Display help message- -V --version Print version information- -h --hello=ITEM-</pre>-<p>- CmdArgs uses defaults to automatically infer a command line parser for a value, and provides annotations to override any of the the defaults. CmdArgs automatically supports <tt>--help</tt> and <tt>--version</tt> flags, and optionally supports verbosity flags.-</p>+CmdArgs uses defaults to automatically infer a command line parser for a value, and provides annotations to override any of the the defaults. CmdArgs automatically supports `--help` and `--version` flags, and optionally supports verbosity flags. -<h2>Specifying Attributes</h2>-<p>- In order to control the behaviour we can add attributes. For example to add an attribute specifying the help text for the <tt>--hello</tt> argument we can write:-</p>-<pre>-sample = Sample{hello = def &= help "Who to say hello to"}-</pre>-<p>- We can add additional attributes, for example to specify the type of the value expected by hello:-</p>-<pre>-sample = Sample {hello = def &= help "Who to say hello to" &= typ "WORLD"}-</pre>-<p>- Now when running <tt>--help</tt> the final line is:-</p>-<pre>- -h --hello=WORLD Who to say hello to-</pre>-<p>- There are many more attributes, detailed in the <a href="http://hackage.haskell.org/packages/archive/cmdargs/latest/doc/html/System-Console-CmdArgs.html#2">Haddock documentation</a>.-</p>+## Specifying Attributes +In order to control the behaviour we can add attributes. For example to add an attribute specifying the help text for the `--hello` argument we can write: -<h2>Multiple Modes</h2>-<p>- To specify a program with multiple modes, similar to <a href="http://darcs.net/">darcs</a>, we can supply a data type with multiple constructors, for example:-</p>+ sample = Sample{hello = def &= help "Who to say hello to"} +We can add additional attributes, for example to specify the type of the value expected by hello:++ sample = Sample {hello = def &= help "Who to say hello to" &= typ "WORLD"}++Now when running `--help` the final line is:++ -h --hello=WORLD Who to say hello to++There are many more attributes, detailed in the [Haddock documentation](http://hackage.haskell.org/packages/archive/cmdargs/latest/doc/html/System-Console-CmdArgs.html#2).+++## Multiple Modes++To specify a program with multiple modes, similar to [darcs](http://darcs.net/), we can supply a data type with multiple constructors, for example: data Sample = Hello {whom :: String} | Goodbye@@ -141,103 +114,96 @@ main = print =<< cmdArgs (modes [hello,goodbye]) -<p>- Compared to the first example, we now have multiple constructors, and a sample value for each constructor is passed to <tt>cmdArgs</tt>. Some sample interactions with this command line are:-</p>-<pre>-$ runhaskell Sample.hs hello --whom=world-Hello {whom = "world"}+Compared to the first example, we now have multiple constructors, and a sample value for each constructor is passed to `cmdArgs`. Some sample interactions with this command line are: -$ runhaskell Sample.hs goodbye-Goodbye+ $ runhaskell Sample.hs hello --whom=world+ Hello {whom = "world"}+ + $ runhaskell Sample.hs goodbye+ Goodbye+ + $ runhaskell Sample.hs --help+ The sample program+ + sample [OPTIONS]+ + Common flags+ -? --help Display help message+ -V --version Print version information+ + sample hello [OPTIONS]+ + -w --whom=ITEM+ + sample goodbye [OPTIONS] -$ runhaskell Sample.hs --help-The sample program+As before, the behaviour can be customised using attributes. -sample [OPTIONS] - Common flags- -? --help Display help message- -V --version Print version information--sample hello [OPTIONS]-- -w --whom=ITEM--sample goodbye [OPTIONS]-</pre>-<p>- As before, the behaviour can be customised using attributes.-</p>--<h2>Larger Examples</h2>+## Larger Examples -<p>- For each of the following examples we first explain the purpose of the program, then give the source code, and finally the output of <tt>--help=HTML</tt>. The programs are intended to show sample uses of CmdArgs, and are available to experiment with through <tt>cmdargs <i>progname</i></tt>.-</p>+For each of the following examples we first explain the purpose of the program, then give the source code, and finally the output of `--help`. The programs are intended to show sample uses of CmdArgs, and are available to experiment with through `cmdargs progname`. -<h3>HLint</h3>+### HLint -<p>- The <a href="http://community.haskell.org/~ndm/hlint/">HLint</a> program analyses a list of files, using various options to control the analysis. The command line processing is simple, but a few interesting points are:-</p>-<ul>- <li>The <tt>--report</tt> flag can be used to output a report in a standard location, but giving the flag a value changes where the file is output.</li>- <li>The <tt>color</tt> field is assigned two flag aliases, <tt>--colour</tt> and <tt>-c</tt>. Assigning the <tt>-c</tt> short flag explicitly stops either of the CPP fields using it.</li>- <li>The <tt>show_</tt> field would clash with <tt>show</tt> if given the expected name, but CmdArgs automatically strips the trailing underscore.</li>- <li>The <tt>cpp_define</tt> field has an underscore in it's name, which is transformed into a hyphen for the flag name.</li>-</ul>+The [HLint](https://github.com/ndmitchell/hlint#readme) program analyses a list of files, using various options to control the analysis. The command line processing is simple, but a few interesting points are: -<!-- BEGIN code hlint -->-<pre>-{-# LANGUAGE DeriveDataTypeable #-}-module HLint where-import System.Console.CmdArgs+* The `--report` flag can be used to output a report in a standard location, but giving the flag a value changes where the file is output.+* The `color` field is assigned two flag aliases, `--colour` and `-c`. Assigning the `-c` short flag explicitly stops either of the CPP fields using it.+* The `show_` field would clash with `show` if given the expected name, but CmdArgs automatically strips the trailing underscore.+* The `cpp_define` field has an underscore in it's name, which is transformed into a hyphen for the flag name. -data HLint = HLint- {report :: [FilePath]- ,hint :: [FilePath]- ,color :: Bool- ,ignore_ :: [String]- ,show_ :: Bool- ,extension :: [String]- ,language :: [String]- ,utf8 :: Bool- ,encoding :: String- ,find :: [FilePath]- ,test_ :: Bool- ,datadir :: [FilePath]- ,cpp_define :: [String]- ,cpp_include :: [FilePath]- ,files :: [FilePath]- }- deriving (Data,Typeable,Show,Eq)+The code is: -hlint = HLint- {report = def &= opt "report.html" &= typFile &= help "Generate a report in HTML"- ,hint = def &= typFile &= help "Hint/ignore file to use"- ,color = def &= name "c" &= name "colour" &= help "Color the output (requires ANSI terminal)"- ,ignore_ = def &= typ "MESSAGE" &= help "Ignore a particular hint"- ,show_ = def &= help "Show all ignored ideas"- ,extension = def &= typ "EXT" &= help "File extensions to search (defaults to hs and lhs)"- ,language = def &= name "X" &= typ "LANG" &= help "Language extension (Arrows, NoCPP)"- ,utf8 = def &= help "Use UTF-8 text encoding"- ,encoding = def &= typ "ENC" &= help "Choose the text encoding"- ,find = def &= typFile &= help "Find hints in a Haskell file"- ,test_ = def &= help "Run in test mode"- ,datadir = def &= typDir &= help "Override the data directory"- ,cpp_define = def &= typ "NAME[=VALUE]" &= help "CPP #define"- ,cpp_include = def &= typDir &= help "CPP include path"- ,files = def &= args &= typ "FILES/DIRS"- } &=- verbosity &=- help "Suggest improvements to Haskell source code" &=- summary "HLint v0.0.0, (C) Neil Mitchell" &=- details ["Hlint gives hints on how to improve Haskell code",""- ,"To check all Haskell files in 'src' and generate a report type:"," hlint src --report"]+ {-# LANGUAGE DeriveDataTypeable #-}+ module HLint where+ import System.Console.CmdArgs+ + data HLint = HLint+ {report :: [FilePath]+ ,hint :: [FilePath]+ ,color :: Bool+ ,ignore_ :: [String]+ ,show_ :: Bool+ ,extension :: [String]+ ,language :: [String]+ ,utf8 :: Bool+ ,encoding :: String+ ,find :: [FilePath]+ ,test_ :: Bool+ ,datadir :: [FilePath]+ ,cpp_define :: [String]+ ,cpp_include :: [FilePath]+ ,files :: [FilePath]+ }+ deriving (Data,Typeable,Show,Eq)+ + hlint = HLint+ {report = def &= opt "report.html" &= typFile &= help "Generate a report in HTML"+ ,hint = def &= typFile &= help "Hint/ignore file to use"+ ,color = def &= name "c" &= name "colour" &= help "Color the output (requires ANSI terminal)"+ ,ignore_ = def &= typ "MESSAGE" &= help "Ignore a particular hint"+ ,show_ = def &= help "Show all ignored ideas"+ ,extension = def &= typ "EXT" &= help "File extensions to search (defaults to hs and lhs)"+ ,language = def &= name "X" &= typ "LANG" &= help "Language extension (Arrows, NoCPP)"+ ,utf8 = def &= help "Use UTF-8 text encoding"+ ,encoding = def &= typ "ENC" &= help "Choose the text encoding"+ ,find = def &= typFile &= help "Find hints in a Haskell file"+ ,test_ = def &= help "Run in test mode"+ ,datadir = def &= typDir &= help "Override the data directory"+ ,cpp_define = def &= typ "NAME[=VALUE]" &= help "CPP #define"+ ,cpp_include = def &= typDir &= help "CPP include path"+ ,files = def &= args &= typ "FILES/DIRS"+ } &=+ verbosity &=+ help "Suggest improvements to Haskell source code" &=+ summary "HLint v0.0.0, (C) Neil Mitchell" &=+ details ["Hlint gives hints on how to improve Haskell code",""+ ,"To check all Haskell files in 'src' and generate a report type:"," hlint src --report"]+ + mode = cmdArgsMode hlint -mode = cmdArgsMode hlint-</pre>+Produces the `--help` output: HLint v0.0.0, (C) Neil Mitchell @@ -245,138 +211,132 @@ Suggest improvements to Haskell source code Common flags:- -r --report[=FILE] Generate a report in HTML- -h --hint=FILE Hint/ignore file to use- -c --colour --color Color the output (requires ANSI terminal)- -i --ignore=MESSAGE Ignore a particular hint+ -r --report[=FILE] Generate a report in HTML+ -h --hint=FILE Hint/ignore file to use+ -c --colour --color Color the output (requires ANSI terminal)+ -i --ignore=MESSAGE Ignore a particular hint -s --show Show all ignored ideas --extension=EXT File extensions to search (defaults to hs and lhs)- -X --language=LANG Language extension (Arrows, NoCPP)- -u --utf8 Use UTF-8 text encoding- --encoding=ENC Choose the text encoding- -f --find=FILE Find hints in a Haskell file- -t --test Run in test mode- -d --datadir=DIR Override the data directory+ -X --language=LANG Language extension (Arrows, NoCPP)+ -u --utf8 Use UTF-8 text encoding+ --encoding=ENC Choose the text encoding+ -f --find=FILE Find hints in a Haskell file+ -t --test Run in test mode+ -d --datadir=DIR Override the data directory --cpp-define=NAME[=VALUE] CPP #define- --cpp-include=DIR CPP include path- -? --help Display help message- -V --version Print version information- -v --verbose Loud verbosity- -q --quiet Quiet verbosity+ --cpp-include=DIR CPP include path+ -? --help Display help message+ -V --version Print version information+ -v --verbose Loud verbosity+ -q --quiet Quiet verbosity Hlint gives hints on how to improve Haskell code To check all Haskell files in 'src' and generate a report type: hlint src --report- --<h3>Diffy</h3>--<p>- The Diffy sample is a based on the idea of creating directory listings and comparing them. The tool can operate in two separate modes, <tt>create</tt> or <tt>diff</tt>. This sample is fictional, but the ideas are drawn from a real program. A few notable features:-</p>-<ul>- <li>There are multiple modes of execution, creating and diffing.</li>- <li>The diff mode takes exactly two arguments, the old file and the new file.</li>- <li>Default values are given for the <tt>out</tt> field, which are different in both modes.</li>-</ul>--<!-- BEGIN code diffy -->-<pre>-{-# LANGUAGE DeriveDataTypeable #-}-module Diffy where-import System.Console.CmdArgs--data Diffy = Create {src :: Maybe FilePath, out :: FilePath}- | Diff {old :: FilePath, new :: FilePath, out :: FilePath}- deriving (Data,Typeable,Show,Eq)--outFlags x = x &= help "Output file" &= typFile--create = Create- {src = def &= help "Source directory" &= typDir- ,out = outFlags "ls.txt"- } &= help "Create a fingerprint"+ -diff = Diff- {old = def &= typ "OLDFILE" &= argPos 0- ,new = def &= typ "NEWFILE" &= argPos 1- ,out = outFlags "diff.txt"- } &= help "Perform a diff"+### Diffy -mode = cmdArgsMode $ modes [create,diff] &= help "Create and compare differences" &= program "diffy" &= summary "Diffy v1.0"-</pre>-<!-- END -->-<!-- BEGIN help diffy -->- Diffy v1.0- - diffy [COMMAND] ... [OPTIONS]- Create and compare differences- - Common flags:- -o --out=FILE Output file- -? --help Display help message- -V --version Print version information- - diffy create [OPTIONS]- Create a fingerprint- - -s --src=DIR Source directory- - diffy diff [OPTIONS] OLDFILE NEWFILE- Perform a diff+The Diffy sample is a based on the idea of creating directory listings and comparing them. The tool can operate in two separate modes, `create` or `diff`. This sample is fictional, but the ideas are drawn from a real program. A few notable features: -<!-- END -->+* There are multiple modes of execution, creating and diffing.+* The diff mode takes exactly two arguments, the old file and the new file.+* Default values are given for the `out` field, which are different in both modes. -<h3>Maker</h3>+The code is: -<p>- The Maker sample is based around a build system, where we can either build a project, clean the temporary files, or run a test. Some interesting features are:-</p>-<ul>- <li>The build mode is the default, so <tt>maker</tt> on it's own will be interpretted as a build command.</li>- <li>The build method is an enumeration.</li>- <li>The <tt>threads</tt> field is in two of the constructors, but not all three. It is given the short flag <tt>-j</tt>, rather than the default <tt>-t</tt>.</li>-</ul>+ {-# LANGUAGE DeriveDataTypeable #-}+ module Diffy where+ import System.Console.CmdArgs+ + data Diffy = Create {src :: Maybe FilePath, out :: FilePath}+ | Diff {old :: FilePath, new :: FilePath, out :: FilePath}+ deriving (Data,Typeable,Show,Eq)+ + outFlags x = x &= help "Output file" &= typFile+ + create = Create+ {src = def &= help "Source directory" &= typDir+ ,out = outFlags "ls.txt"+ } &= help "Create a fingerprint"+ + diff = Diff+ {old = def &= typ "OLDFILE" &= argPos 0+ ,new = def &= typ "NEWFILE" &= argPos 1+ ,out = outFlags "diff.txt"+ } &= help "Perform a diff"+ + mode = cmdArgsMode $ modes [create,diff] &= help "Create and compare differences" &= program "diffy" &= summary "Diffy v1.0" +And `--help` produces: -<!-- BEGIN code maker -->-<pre>-{-# LANGUAGE DeriveDataTypeable #-}-module Maker where-import System.Console.CmdArgs+ Diffy v1.0+ + diffy [COMMAND] ... [OPTIONS]+ Create and compare differences+ + Common flags:+ -o --out=FILE Output file+ -? --help Display help message+ -V --version Print version information+ + diffy create [OPTIONS]+ Create a fingerprint+ + -s --src=DIR Source directory+ + diffy diff [OPTIONS] OLDFILE NEWFILE+ Perform a diff -data Method = Debug | Release | Profile- deriving (Data,Typeable,Show,Eq)+### Maker -data Maker- = Wipe- | Test {threads :: Int, extra :: [String]}- | Build {threads :: Int, method :: Method, files :: [FilePath]}- deriving (Data,Typeable,Show,Eq)+The Maker sample is based around a build system, where we can either build a project, clean the temporary files, or run a test. Some interesting features are: -threadsMsg x = x &= help "Number of threads to use" &= name "j" &= typ "NUM"+* The build mode is the default, so `maker` on it's own will be interpreted as a build command.+* The build method is an enumeration.+* The `threads` field is in two of the constructors, but not all three. It is given the short flag `-j`, rather than the default `-t`. -wipe = Wipe &= help "Clean all build objects"+The code is: -test_ = Test- {threads = threadsMsg def- ,extra = def &= typ "ANY" &= args- } &= help "Run the test suite"+ {-# LANGUAGE DeriveDataTypeable #-}+ module Maker where+ import System.Console.CmdArgs+ + data Method = Debug | Release | Profile+ deriving (Data,Typeable,Show,Eq)+ + data Maker+ = Wipe+ | Test {threads :: Int, extra :: [String]}+ | Build {threads :: Int, method :: Method, files :: [FilePath]}+ deriving (Data,Typeable,Show,Eq)+ + threadsMsg x = x &= help "Number of threads to use" &= name "j" &= typ "NUM"+ + wipe = Wipe &= help "Clean all build objects"+ + test_ = Test+ {threads = threadsMsg def+ ,extra = def &= typ "ANY" &= args+ } &= help "Run the test suite"+ + build = Build+ {threads = threadsMsg def+ ,method = enum+ [Release &= help "Release build"+ ,Debug &= help "Debug build"+ ,Profile &= help "Profile build"]+ ,files = def &= args+ } &= help "Build the project" &= auto+ + mode = cmdArgsMode $ modes [build,wipe,test_]+ &= help "Build helper program"+ &= program "maker"+ &= summary "Maker v1.0\nMake it" -build = Build- {threads = threadsMsg def- ,method = enum- [Release &= help "Release build"- ,Debug &= help "Debug build"- ,Profile &= help "Profile build"]- ,files = def &= args- } &= help "Build the project" &= auto+And `--help` produces: -mode = cmdArgsMode $ modes [build,wipe,test_] &= help "Build helper program" &= program "maker" &= summary "Maker v1.0\nMake it"-</pre>-<!-- END -->-<!-- BEGIN help maker --> Maker v1.0 Make it @@ -402,4 +362,3 @@ Run the test suite -j --threads=NUM Number of threads to use-<!-- END -->
System/Console/CmdArgs/Test/Implicit/Tests.hs view
@@ -266,12 +266,12 @@ data Test15 = Test15 {test15a :: Bool} deriving (Eq,Show,Data,Typeable) mode15 = cmdArgsMode $ Test15 (False &= name "help")- &= helpArg [groupname "GROUP", name "h", name "nohelp", explicit, help "whatever"] &= versionArg [ignore]+ &= helpArg [groupname "GROUP", name "h", name "nohelp", explicit, help "whatever\nstuff"] &= versionArg [ignore] &= verbosityArgs [ignore] [explicit,name "silent"] $(cmdArgsQuote [d| mode15_ = cmdArgsMode# $ Test15 (False &=# name "help")- &=# helpArg [groupname "GROUP", name "h", name "nohelp", explicit, help "whatever"] &=# versionArg [ignore]+ &=# helpArg [groupname "GROUP", name "h", name "nohelp", explicit, help "whatever\nstuff"] &=# versionArg [ignore] &=# verbosityArgs [ignore] [explicit,name "silent"] |])
System/Console/CmdArgs/Text.hs view
@@ -107,7 +107,7 @@ -- | Split the text into strips of no-more than the given width wrap :: Int -> String -> [String]-wrap width = combine . split+wrap width = concatMap (combine . split) . lines where split :: String -> [(String,Int)] -- string, amount of space after split "" = []@@ -131,18 +131,24 @@ map f xs ++ ["</table>"] where- cols = maximum [length x | Cols x <- xs]+ maxCols = maximum [length x | Cols x <- xs] - f (Line x) = tr $ td cols x- f (Cols xs) = tr $ concatMap (td 1) (init xs) ++ td (cols + 1 - length xs) (last xs)+ f (Line x) = tr $ td maxCols x+ f (Cols xs) = tr $ concatMap (td 1) (init xs) ++ td (maxCols + 1 - length xs) (last xs) tr x = "<tr>" ++ x ++ "</tr>" td cols x = "<td" ++ (if cols == 1 then "" else " colspan='" ++ show cols ++ "'")- ++ (if a /= "" then " style='padding-left:" ++ show (length a) ++ "ex;'" else "") +++ ++ (if null styles then "" else " style='" ++ unwords styles ++ "'") ++ ">" ++ if null b then " " else concatMap esc b ++ "</td>" where (a,b) = span isSpace x+ -- if the first letter of the contents is '-', assume this is a flag+ -- and be aware that HTML might try to line-break it, see #39+ isFlag = take 1 b == "-"+ styles = [ "padding-left:" ++ show (length a) ++ "ex;" | a /= "" ]+ ++ [ "white-space:nowrap;" | isFlag ] esc '&' = "&" esc '>' = ">" esc '<' = "<"+ esc '\n' = "<br />" esc x = [x]
cmdargs.cabal view
@@ -1,13 +1,13 @@ cabal-version: >= 1.6 build-type: Simple name: cmdargs-version: 0.10.13+version: 0.10.14 license: BSD3 license-file: LICENSE category: Console author: Neil Mitchell <ndmitchell@gmail.com> maintainer: Neil Mitchell <ndmitchell@gmail.com>-copyright: Neil Mitchell 2009-2015+copyright: Neil Mitchell 2009-2016 synopsis: Command line argument processing description: This library provides an easy way to define command line parsers. Most users@@ -29,11 +29,11 @@ For a general reference on what command line flags are commonly used, see <http://www.faqs.org/docs/artu/ch10s05.html>. bug-reports: https://github.com/ndmitchell/cmdargs/issues-homepage: http://community.haskell.org/~ndm/cmdargs/-extra-source-files:+homepage: https://github.com/ndmitchell/cmdargs#readme+extra-doc-files: README.md CHANGES.txt-tested-with: GHC==7.10.1, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2+tested-with: GHC==8.0.1, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2 source-repository head type: git