Safe Haskell | Safe |
---|---|
Language | Haskell98 |
The CLTokens module describes non-overlapping classes of strings that are useful for disambiguating arguments to command line programs. Many common string formats -- environment variable assignments, URLs, option strings -- are recognized by this module's utilities.
Synopsis
- data Class
- = EnvBinding
- | QualifiedPath
- | DashDash
- | LongOption
- | Dash
- | ShortOption
- | URL
- | HexNum
- | DecimalNum
- | Size
- match :: Class -> ByteString -> Bool
- recognize :: ByteString -> Maybe Class
- exemplar :: Class -> ByteString
- recognizer :: Class -> Parser ()
- schemeSeparator :: Parser ByteString Word8
- varFirst :: Char -> Bool
- varBody :: Char -> Bool
- isLongOptionChar :: Char -> Bool
- isShortOptionChar :: Char -> Bool
- isSchemeChar :: Char -> Bool
- isHexDigit :: Char -> Bool
- isURLSchemeChar :: Char -> Bool
- sizes :: Map ByteString Integer
- size :: Parser Integer
- sizeBounded :: forall b. (Bounded b, Integral b) => Parser b
Documentation
Non-overlapping classes of command line argument strings.
EnvBinding | An |
QualifiedPath | A |
DashDash | A |
LongOption | A |
Dash | A |
ShortOption | A |
URL | A |
HexNum | A |
DecimalNum | A |
Size | A |
match :: Class -> ByteString -> Bool Source #
Determine if a particular ByteString
matches the given Class
of token.
recognize :: ByteString -> Maybe Class Source #
Determine if a particular ByteString
matches any Class
of token.
exemplar :: Class -> ByteString Source #
A ByteString stand-in that demoes each token class.
recognizer :: Class -> Parser () Source #
The recognizer appropriate to each token class. Parses successfully if a
the token class is recognized, returning '()'. Most token types are
defined in terms of a prefix of the input -- for example, QualifiedPath
-- and the parsers for these tokens naturally return as soon as the prefix
is recognized.
isLongOptionChar :: Char -> Bool Source #
isShortOptionChar :: Char -> Bool Source #
isSchemeChar :: Char -> Bool Source #
isHexDigit :: Char -> Bool Source #
isURLSchemeChar :: Char -> Bool Source #
sizes :: Map ByteString Integer Source #
A map from suffixes to sizes, following the conventions of command line
tools (GNU dd
or head
and many others) as well as the standard for
binary sizes established by the IEC.
B = 1
K = KiB = 1024B kB = 1000B
M = MiB = 1024K MB = 1000kB
G = GiB = 1024M GB = 1000MB
T = TiB = 1024G TB = 1000GB
P = PiB = 1024T PB = 1000TB
E = EiB = 1024P EB = 1000PB
Z = ZiB = 1024E ZB = 1000EB
Y = YiB = 1024Z YB = 1000ZB