Draft: explore type state for FSRepository #924
Closed
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.
Exploring the idea of using the type state pattern to have two different flavors of an
FSRepository
, one that promises the user's renders directory exists, and one that doesn't, for use by cmd_clean (#923).There are some type conversion todos left in the code, but I got this to the point where the non-test code will compile and in theory
spfs clean
would not attempt to create the user's render directory.Looking for feedback on this approach or if there are any suggestions for an alternative approach. Something much simpler would be the tried and true pass-a-bool-down, since all I really want to accomplish is to skip creating one of the directories inside
create
. There's just a lot of abstraction betweenopen_repository_from_string
and the call tocreate
.This draft change doesn't offer any other advantages, like it doesn't prevent using a no-renders repo as if it were a yes-renders one. The distinction gets hidden behind the
RepositoryHandle
. I guess I'm saying I don't like this code but I thought I'd at least get a second opinion.