arx-0.0.1: Archive execution tool.



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.



data Class Source

Non-overlapping classes of command line argument strings.



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


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


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


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


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


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


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:


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


A DecimalNum is a string of decimal digits: 123123.


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.


match :: Class -> ByteString -> BoolSource

Determine if a particular ByteString matches the given Class of token.

recognize :: ByteString -> Maybe ClassSource

Determine if a particular ByteString matches any Class of token.

exemplar :: Class -> ByteStringSource

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 IntegerSource

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 IntegerSource

Parse a size, consuming the entire input string.

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

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