Use ConfigurationParser library to parse configuration#120
Merged
liamnichols merged 9 commits intomainCreateAPI/CreateAPI:mainfrom Aug 8, 2022
ln/swift-configuration-parserCreateAPI/CreateAPI:ln/swift-configuration-parserCopy head branch name to clipboard
Merged
Use ConfigurationParser library to parse configuration#120liamnichols merged 9 commits intomainCreateAPI/CreateAPI:mainfrom ln/swift-configuration-parserCreateAPI/CreateAPI:ln/swift-configuration-parserCopy head branch name to clipboard
liamnichols merged 9 commits intomainCreateAPI/CreateAPI:mainfrom
ln/swift-configuration-parserCreateAPI/CreateAPI:ln/swift-configuration-parserCopy head branch name to clipboard
Conversation
8af1098 to
e48f167
Compare
…m behaviours in StringCodingContainer
e48f167 to
f908b40
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Background
While it was only recently that I introduces Sourcery templates for generating decoder logic for the
ConfigOptionsfile, it actually lead me to take some inspiration from Swift Argument Parser and to write my own mini library called ConfigurationParser.Similar to ArgumentParser, it lets you define
ParsableConfigurationtypes and brings all kinds of useful improvements compared to just decoding data usingYAMLDecoderthat we had been taking advantage of.The result is that a lot of the custom decoding code written in the CreateOptions target is now no longer required. In this change I delete it all and I update
ConfigOptionsto become aParsableConfigurationtype which involves the following:ParsableConfigurationprotocol (no requirements other thaninit()@OptionConfigOptions.optionswhich is powerful (read on).Since I deleted the custom decoding code, I did also have to make up for it since that's how #111 worked. To combat this, I introduced a small
@OptionSetDecodableproperty wrapper that handles things.While in this change we are just using the library to replicate what we previously did manually, there are two other powerful features that I hope to take advantage of:
Overrides
ConfigurationParser allows you to pass overrides when parsing, we can pull these from the CLI arguments which helps with #47 because in theory you can override anything via the command line arguments.
Documentation
The
@Optionannotation lets you include documentation and we can leverage this with a plugin that can replace Sourcery in terms of generating documentation.