1- package processing.app.contrib
1+ package processing.app.api
22
33import com.github.ajalt.clikt.command.SuspendingCliktCommand
44import com.github.ajalt.clikt.core.Context
55import com.github.ajalt.clikt.core.subcommands
66import kotlinx.serialization.Serializable
77import kotlinx.serialization.encodeToString
8+ import kotlinx.serialization.json.Json
89import processing.app.Base
10+ import processing.app.api.Sketch.Companion.getSketches
911import java.io.File
10- import kotlinx.serialization.json.*
11-
1212
1313class Contributions : SuspendingCliktCommand (){
1414 override fun help (context : Context ) = " Manage Processing contributions"
@@ -47,7 +47,7 @@ class Contributions: SuspendingCliktCommand(){
4747 val sketches : List <Sketch > = emptyList()
4848 )
4949
50- val serializer = Json {
50+ val serializer = Json {
5151 prettyPrint = true
5252 }
5353
@@ -61,7 +61,7 @@ class Contributions: SuspendingCliktCommand(){
6161 val javaMode = " $resourcesDir /modes/java"
6262 val javaModeExamples = " $javaMode /examples"
6363
64- val javaExamples = getExamples (File (javaModeExamples))
64+ val javaExamples = getSketches (File (javaModeExamples))
6565
6666 val json = serializer.encodeToString(listOf (javaExamples))
6767 println (json)
@@ -74,22 +74,6 @@ class Contributions: SuspendingCliktCommand(){
7474 // Mode examples
7575 }
7676
77- suspend fun getExamples (file : File ): Folder {
78- val name = file.name
79- val (sketchesFolders, childrenFolders) = file.listFiles().partition { isExampleFolder(it) }
8077
81- val children = childrenFolders.map { getExamples(it) }
82- val sketches = sketchesFolders.map { Sketch (name = it.name, path = it.absolutePath) }
83- return Folder (
84- name = name,
85- path = file.absolutePath,
86- children = children,
87- sketches = sketches
88- )
89- }
90- fun isExampleFolder (file : File ): Boolean {
91- return file.isDirectory && file.listFiles().any { it.isFile && it.name.endsWith(" .pde" ) }
92- }
9378 }
94- }
95-
79+ }
0 commit comments