@@ -85,58 +85,55 @@ internal object ListPatchesCommand : Runnable {
8585 }
8686 }
8787
88- fun PatchOption <* >.buildString () =
88+ fun PatchOption <* >.buildString () = buildString {
89+ appendLine(" Title: $title " )
90+ description?.let { appendLine(" Description: $it " ) }
91+ appendLine(" Required: $required " )
92+ default?.let {
93+ appendLine(" Key: $key " )
94+ append(" Default: $it " )
95+ } ? : append(" Key: $key " )
96+
97+ values?.let { values ->
98+ appendLine(" \n Possible values:" )
99+ append(values.map { " ${it.value} (${it.key} )" }.joinToString(" \n " ).prependIndent(" \t " ))
100+ }
101+
102+ append(" \n Type: $type " )
103+ }
104+
105+ fun IndexedValue <Patch <* >>.buildString () = let { (index, patch) ->
89106 buildString {
90- appendLine(" Title: $title " )
91- description?.let { appendLine(" Description: $it " ) }
92- appendLine(" Required: $required " )
93- default?.let {
94- appendLine(" Key: $key " )
95- append(" Default: $it " )
96- } ? : append(" Key: $key " )
97-
98- values?.let { values ->
99- appendLine(" \n Possible values:" )
100- append(values.map { " ${it.value} (${it.key} )" }.joinToString(" \n " ).prependIndent(" \t " ))
101- }
107+ if (withIndex) appendLine(" Index: $index " )
102108
103- append(" \n Type: $type " )
104- }
109+ append(" Name: ${patch.name} " )
105110
106- fun IndexedValue <Patch <* >>.buildString () =
107- let { (index, patch) ->
108- buildString {
109- if (withIndex) appendLine(" Index: $index " )
110-
111- append(" Name: ${patch.name} " )
112-
113- if (withDescriptions) append(" \n Description: ${patch.description} " )
114-
115- append(" \n Enabled: ${patch.use} " )
116-
117- if (withOptions && patch.options.isNotEmpty()) {
118- appendLine(" \n Options:" )
119- append(
120- patch.options.values.joinToString(" \n\n " ) { option ->
121- option.buildString()
122- }.prependIndent(" \t " ),
123- )
124- }
125-
126- if (withPackages && patch.compatiblePackages != null ) {
127- appendLine(" \n Compatible packages:" )
128- append(
129- patch.compatiblePackages!! .joinToString(" \n " ) {
130- it.buildString()
131- }.prependIndent(" \t " ),
132- )
133- }
111+ if (withDescriptions) patch.description?.let { append(" \n Description: $it " ) }
112+
113+ append(" \n Enabled: ${patch.use} " )
114+
115+ if (withOptions && patch.options.isNotEmpty()) {
116+ appendLine(" \n Options:" )
117+ append(
118+ patch.options.values.joinToString(" \n\n " ) { option ->
119+ option.buildString()
120+ }.prependIndent(" \t " ),
121+ )
122+ }
123+
124+ if (withPackages && patch.compatiblePackages != null ) {
125+ appendLine(" \n Compatible packages:" )
126+ append(
127+ patch.compatiblePackages!! .joinToString(" \n " ) {
128+ it.buildString()
129+ }.prependIndent(" \t " ),
130+ )
134131 }
135132 }
133+ }
136134
137- fun Patch <* >.filterCompatiblePackages (name : String ) =
138- compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name }
139- ? : withUniversalPatches
135+ fun Patch <* >.filterCompatiblePackages (name : String ) = compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name }
136+ ? : withUniversalPatches
140137
141138 val patches = loadPatchesFromJar(patchesFiles).withIndex().toList()
142139
0 commit comments