@@ -4,45 +4,49 @@ import com.github.ajalt.clikt.command.SuspendingCliktCommand
4
4
import com.github.ajalt.clikt.command.main
5
5
import com.github.ajalt.clikt.core.Context
6
6
import com.github.ajalt.clikt.core.subcommands
7
+ import com.github.ajalt.clikt.parameters.arguments.argument
8
+ import com.github.ajalt.clikt.parameters.arguments.multiple
7
9
import com.github.ajalt.clikt.parameters.options.flag
8
10
import com.github.ajalt.clikt.parameters.options.option
9
11
import processing.app.ui.Start
10
12
11
- // TODO: Allow Start to run on no args
12
- // TODO: Modify InstallCommander to use the new structure
13
- // TODO: Move dependency to gradle toml
14
- // TODO: Add the options/arguments for Base arguments
15
- class Processing ( val args : Array < String >): SuspendingCliktCommand(name = " Processing " ){
13
+ class Processing : SuspendingCliktCommand ( " processing " ){
14
+ val sketches by argument().multiple(default = emptyList())
15
+
16
+ override fun help ( context : Context ) = " Start the Processing IDE "
17
+ override val invokeWithoutSubcommand = true
16
18
override suspend fun run () {
17
- if (currentContext.invokedSubcommand == null ){
18
- Start .main(args)
19
+ val subcommand = currentContext.invokedSubcommand
20
+ if (subcommand == null ) {
21
+ Start .main(sketches.toTypedArray())
19
22
}
20
23
}
21
24
}
22
25
23
- suspend fun main (args : Array <String >) = Processing (args)
24
- .subcommands(
25
- LSP (args),
26
- LegacyCLI (args)
27
- )
28
- .main(args)
29
-
26
+ suspend fun main (args : Array <String >){
27
+ Processing ()
28
+ .subcommands(
29
+ LSP (),
30
+ LegacyCLI (args)
31
+ )
32
+ .main(args)
33
+ }
30
34
31
- class LSP ( val args : Array < String >) : SuspendingCliktCommand(" lsp" ){
35
+ class LSP : SuspendingCliktCommand (" lsp" ){
32
36
override fun help (context : Context ) = " Start the Processing Language Server"
33
37
override suspend fun run (){
34
38
try {
35
39
// Indirect invocation since app does not depend on java mode
36
40
Class .forName(" processing.mode.java.lsp.PdeLanguageServer" )
37
41
.getMethod(" main" , Array <String >::class .java)
38
- .invoke(null , * arrayOf<Any >(args ))
42
+ .invoke(null , * arrayOf<Any >(emptyList< String >() ))
39
43
} catch (e: Exception ) {
40
44
throw InternalError (" Failed to invoke main method" , e)
41
45
}
42
46
}
43
47
}
44
48
45
- class LegacyCLI (val args : Array <String >): SuspendingCliktCommand(name = " cli" ){
49
+ class LegacyCLI (val args : Array <String >): SuspendingCliktCommand( " cli" ){
46
50
override fun help (context : Context ) = " Legacy processing-java command line interface"
47
51
48
52
val help by option(" --help" ).flag()
@@ -57,12 +61,15 @@ class LegacyCLI(val args: Array<String>): SuspendingCliktCommand(name = "cli"){
57
61
val variant: String? by option(" --variant" )
58
62
59
63
override suspend fun run (){
60
- val cliArgs = args.filter { it != " cli" }.toTypedArray()
64
+ val cliArgs = args.filter { it != " cli" }
61
65
try {
66
+ if (build){
67
+ System .setProperty(" java.awt.headless" , " true" )
68
+ }
62
69
// Indirect invocation since app does not depend on java mode
63
70
Class .forName(" processing.mode.java.Commander" )
64
71
.getMethod(" main" , Array <String >::class .java)
65
- .invoke(null , * arrayOf<Any >(cliArgs))
72
+ .invoke(null , * arrayOf<Any >(cliArgs.toTypedArray() ))
66
73
} catch (e: Exception ) {
67
74
throw InternalError (" Failed to invoke main method" , e)
68
75
}
0 commit comments