plade library

Classes

AppArgParser
An argument parser, the primary entry point to this library.
Arg<T>
A holder for the eventual value of an argument.
ArgConfig
A set of configuration options that can be passed to an ArgParser.
ArgParser
A base argument parser, shared by AppArgParser and CommandParser.
ArgParsingError
An exception thrown when parsing arguments fails.
CommandParser
An ArgParser returned by CommandSet.addCommand that adds arguments to a single command.
CommandSet<T>
A set of commands that can be parsed by its parent ArgParser.
PrefixInverseGenerator
An implementation of InverseGenerator that can either swap an argument's prefix for another, or append a new "generic" prefix if none of the known swap mappings are present.
Requires<U>
A representation of the requirement state of an argument. Can mandate that the argument is mandatory or optional (with a default).
UsageGroup
A group that arguments can be associated with, so that the arguments will be grouped under this group's name in the usage text.
UsageInfo
A set of information that should be printed on the program's usage text.

Enums

ArgParsingErrorKind
The kind of argument parsing error encountered.

Extensions

FunctionComposition on R Function(A)
A set of utilities for composing single-argument functions together.
ValueParserExtensions on ValueParser<T>
ValueParserFlagExtensions on ValueParser<bool>

Constants

disableFlagInverse → const String
Can be passed to the inverse argument of ArgParser flag methods to disable the inverse completely. See ArgParser.addMultiFlag for more information.

Properties

boolValueParser ValueParser<bool>
A ValueParser that parses boolean values using stringChoiceValueParser.
final

Functions

choiceValueParser<T>(List<T> choices, ValueParser<T> unconstrainedParser, {ValuePrinter<T>? printer}) ValueParser<T>
Returns a ValueParser that constraints an already-parsed value to some sequence of acceptable inputs. See ValueParserExtensions.choice for a slightly more elegant alternative.
discardAccumulator<T>({required T value, T? previous}) → T
An Accumulator that discards all values but the last.
enumChoiceValueParser<T>(List<T> values, {ValuePrinter<String>? interceptPrinter}) ValueParser<T>
A specialization of stringChoiceValueParser that uses enumValuePrinter by default in order to parse enums.
enumValuePrinter<T>(T value) String
A variant of toStringValuePrinter designed for enum values. Since toString() on an enum returns Enum.value, this printer strips off the Enum. prefix.
flagCountAccumulator({required bool value, int? previous}) int
An Accumulator for flag arguments that counts the number of times the argument was true, minus the number of times the argument was false. May return a value less than 0 if more false values are given than true values.
idValueParser(String s) String
A ValueParser that simply returns the original string.
intValueParser(String s) int
A ValueParser that attempts to parse the string as an int. If you need a custom radix, use intValueParserWithRadix.
intValueParserWithRadix(int radix) ValueParser<int>
A ValueParser like intValueParser but takes a custom radix.
listAccumulator<T>({required T value, List<T>? previous}) List<T>
An Accumulator that adds all the values to a list.
negateFlagValueParser(ValueParser<bool> parser) ValueParser<bool>
A ValueParser that wraps another ValueParser<bool> but flips the value. See ValueParserFlagExtensions.negateFlag for a slightly more elegant alternative.
setAccumulator<T>({required T value, Set<T>? previous}) Set<T>
An Accumulator that adds all the values to a set.
stringChoiceValueParser<T>(List<T> choices, {ValuePrinter<T>? printer}) ValueParser<T>
Returns a ValueParser that will stringify each choice using the given printer (defaults to toStringValuePrinter()) and returns a value parser that will map a choice's string to the choice value.
toStringValuePrinter<T>(T value) String
A default ValuePrinter that simply calls Object.toString().

Typedefs

Accumulator<T, U> = U Function({U? previous, required T value})
A function that takes a newly parsed argument value value and a potentially existing accumulated value previous and returns a new accumulated value. In other words, this is very similar to Iterable.reduce, but designed for Plade.
InverseGenerator = String? Function(String name)
A "generator" of an inverse argument for a flag. An inverse generator is given the name of a flag (e.g. for -x it would be x) and should return a string of its inverse (e.g. no-x), or null if no inverse should be used.
ValueParser<T> = T Function(String s)
A function that takes in a string and parses it, returning some result value of type T. If the value cannot be parsed, a ValueParserException should be thrown.
ValuePrinter<T> = String Function(T value)
A function that will stringify the given value, primarily for help messages or for parsing.

Exceptions / Errors

ValueParserException
An exception thrown by a ValueParser when it cannot parse the provided string.