This uses cuttlefish's datatype conversion routines to automatically
parse kvargs and flags. This relieves the burden of conversion from the
user and resolves the issue of needing to customize error messages
emitted from typecast functions, because cuttlefish already provides
them. See basho/clique#44.
In order to maintain the same functionality provided by typecast (for
example, clique_typecast:to_node/1), an additional 'validator' option is
now recognized. The validator will be called after type conversion.
While adding these features, the proplist options seemed to be
complicating too much of the code, so the internal representation of an
arg or flag spec was converted to a record with all the necessary
fields. Users of the code will not need to change passed arguments
because the record is only used internally for efficiency and
clarity. Additionally, the record enables us to avoid calling
list_to_atom/1 on user input in the parser, and instead use simple
matching and lists:keyfind instead. All atom creation is done when
registering the command, improving safety.
This uses cuttlefish's datatype conversion routines to automatically parse kvargs and flags. This relieves the burden of conversion from the user and resolves the issue of needing to customize error messages emitted from typecast functions, because cuttlefish already provides them. See basho/clique#44.
In order to maintain the same functionality provided by typecast (for example, clique_typecast:to_node/1), an additional 'validator' option is now recognized. The validator will be called after type conversion.
While adding these features, the proplist options seemed to be complicating too much of the code, so the internal representation of an arg or flag spec was converted to a record with all the necessary fields. Users of the code will not need to change passed arguments because the record is only used internally for efficiency and clarity. Additionally, the record enables us to avoid calling list_to_atom/1 on user input in the parser, and instead use simple matching and lists:keyfind instead. All atom creation is done when registering the command, improving safety.