arx-0.3.1: Archive execution tool.

Safe HaskellSafe
LanguageHaskell98

System.Posix.ARX.CLI.CLTokens

Description

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

Documentation

data Class Source #

Non-overlapping classes of command line argument strings.

Constructors

EnvBinding

An EnvBinding has the form var name=string. For example, SENDIN=the_clowns.

QualifiedPath

A QualifiedPath is a file path starting with /, ./, or ../.

DashDash

A DashDash is a string of two dashes, --, commonly used to indicate the end of options processing.

LongOption

A LongOption is a string beginning with two dashes and then at least one non-dash.

Dash

A Dash is a single dash, -, commonly used to indicate input from stdin or output to stdout.

ShortOption

A ShortOption is a beginning with a dash and then at least one non-dash.

URL

A URL is a scheme, separated from the resource, represented as an arbitrary string, by ://. The scheme consists of ASCII, lower-case letters and digits, and may be multi-part, with each part separated by a + or / (for example, git+ssh). An example URL: http://example.com/?q=special.

HexNum

A HexNum is a sequence of hexadecimal digits, upper or lower case, beginning with 0x; for example: 0x01a3.

DecimalNum

A DecimalNum is a string of decimal digits: 123123.

Size

A Size is a decimal number followed by a multiplicative suffix, in the manner of dd or head. Note that counts in terms of bytes require B (unlike dd or head). For a full list of suffixes, see sizes below.

Instances

Eq Class Source # 

Methods

(==) :: Class -> Class -> Bool #

(/=) :: Class -> Class -> Bool #

Ord Class Source # 

Methods

compare :: Class -> Class -> Ordering #

(<) :: Class -> Class -> Bool #

(<=) :: Class -> Class -> Bool #

(>) :: Class -> Class -> Bool #

(>=) :: Class -> Class -> Bool #

max :: Class -> Class -> Class #

min :: Class -> Class -> Class #

Show Class Source # 

Methods

showsPrec :: Int -> Class -> ShowS #

show :: Class -> String #

showList :: [Class] -> ShowS #

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.

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

size :: Parser Integer Source #

Parse a size, consuming the entire input string.

sizeBounded :: forall b. (Bounded b, Integral b) => Parser b Source #

Parse a size, consuming the entire input string, with the final result bounded by the maximum of a Bounded type.