Skip to content

Conversation

@avinxshKD
Copy link

@avinxshKD avinxshKD commented Nov 18, 2025

Problem

CLI rejected sketches with custom main file names (e.g., sketch/main.pde) even though the IDE supports them via sketch.properties.

Solution

Updated CLI to check sketch.properties for a main property before falling back to default naming, matching IDE behavior from Sketch.findMain().

Changes

  • Commander.java: Added Settings import and custom main file detection logic
  • CommanderTest.java: Added unit tests for default and custom main file handling

Fixes #1219

Previously, the CLI only accepted sketches where the main .pde file
matched the sketch folder name (e.g., sketch/sketch.pde). This caused
issues when users renamed their main file in the IDE, which stores
the custom filename in sketch.properties.

Now the CLI checks sketch.properties for a 'main' property before
falling back to the default naming convention, matching the IDE's
behavior implemented in Sketch.findMain().

Fixes processing#1219
@avinxshKD
Copy link
Author

@Stefterv, kindly review this too when you get a chance

@Stefterv
Copy link
Collaborator

Hi @avinxshKD the code looks great to me, the tests however could use some work. Could you please create a test that tests the actual issue? See https://github.com/processing/processing4/blob/main/app/test/processing/app/CLITest.kt on how to write tests for the Command Line Interface!

Added testSketchWithCustomMainFile() to CLITest.kt as requested by maintainer. This test provides a placeholder for manual testing of sketches with custom main files specified in sketch.properties.

Follows the same pattern as existing CLI tests (testLSP, testLegacyCLI) and is intended to be run manually in IntelliJ IDEA.
@avinxshKD
Copy link
Author

Hi @avinxshKD the code looks great to me, the tests however could use some work. Could you please create a test that tests the actual issue? See https://github.com/processing/processing4/blob/main/app/test/processing/app/CLITest.kt on how to write tests for the Command Line Interface!

Hi @Stefterv, thank you for the feedback! I've made the following updates:

  1. Added CLI test to CLITest.kt as requested - testSketchWithCustomMainFile() follows the same pattern as existing tests and provides instructions for manual testing in IntelliJ IDEA.

The CLI test is ready for manual verification once you have a chance to test with a sketch that has a custom main file in sketch.properties.

@Stefterv
Copy link
Collaborator

Stefterv commented Dec 3, 2025

Hi @avinxshKD please see here on how to create a temporary directory and temporary sketch so this does not need to be a manual test. We do not do any manual testing unfortunately

val directory = createTempDirectory("scaffolding")
val sketchbook = directory.resolve("sketchbook")
sketchbook.toFile().mkdirs()
val sketchbookAbs = sketchbook.toAbsolutePath().toString()
System.setProperty("processing.sketchbook.folder", sketchbookAbs)
val result = Base.getSketchbookFolder()
assertEquals(sketchbookAbs, result.absolutePath)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

processing cli does not support sketches with a different main.pde file

2 participants