-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace announce struct with additional state
It was identified that calling `announce().warning("").end_announce` is "weird" which I agree with. It exists due to a desire to tame newlines when toggling between multiple warnings/errors and "normal" output, more below. The prior implementation was shaped by the limitations of boxed traits. With that out of the way, this implementation swaps `struct Announce` for `BuildpackOutput<state::Announce<T>>` where T is the "return type". Imagine the states going something like this: ``` Section -> Announce<Section> -> Section or Section -> Announce<Section> -> Announce<Section> -> Section or Started -> Announce<Started> -> Started or Started -> Announce<Started> -> Announce<Started> -> Started ``` The `Announce<T>` state is entered any time a `warning()` or `important()` is called. It is exited when a function from SectionMarker or StartedMarker is called that will output to the UI. This works, because those functions always return a `BuildpackOutput<Section>` or `BuildpackOutput<Started>` and effectively act as an exit of the Announce state. The downside to this approach is that any methods that do not consume, must be implemented separately, like `mut_step()`.
- Loading branch information
Showing
2 changed files
with
109 additions
and
158 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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