Introduce spec record for args and flags, datatypes, and validators. #45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 #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.