File tree Expand file tree Collapse file tree
Sources/AppStoreConnectCLI/Readers and Renderers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,3 +113,42 @@ extension ResultRenderable where Self: TableInfoProvider {
113113 return table. render ( )
114114 }
115115}
116+
117+ protocol SyncResultRenderable {
118+ var syncResultText : String { get }
119+ }
120+
121+ enum SyncStrategy < T: SyncResultRenderable > {
122+ case delete( T )
123+ case create( T )
124+ case update( T )
125+ }
126+
127+ extension Renderers {
128+
129+ struct SyncResultRenderer < T: SyncResultRenderable > {
130+
131+ func render( _ strategy: [ SyncStrategy < T > ] , isDryRun: Bool ) {
132+ strategy. forEach { renderResultText ( $0, isDryRun) }
133+ }
134+
135+ func render( _ strategy: SyncStrategy < T > , isDryRun: Bool ) {
136+ renderResultText ( strategy, isDryRun)
137+ }
138+
139+ private func renderResultText( _ strategy: SyncStrategy < T > , _ isDryRun: Bool ) {
140+ let resultText : String
141+ switch strategy {
142+ case . create( let input) :
143+ resultText = " ➕ \( input. syncResultText) "
144+ case . delete( let input) :
145+ resultText = " ➖ \( input. syncResultText) "
146+ case . update( let input) :
147+ resultText = " ⬆️ \( input. syncResultText) "
148+ }
149+
150+ print ( " \( isDryRun ? " " : " ✅ " ) \( resultText) " )
151+ }
152+ }
153+
154+ }
You can’t perform that action at this time.
0 commit comments