Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork436
Enable creating new sketches from a template directory#2359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
cmaglie left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
One question how to handle setting sketchMainFilePath. Should we rename some file in the template directory to MySketch.ino? Or just pick a .ino from the directory (ideally there's only one) and return that from the RPC call?
mmmhh... It's a bit more convoluted than expected, we should consider these factors:
- A sketch may be composed of many files
- Themain sketch file is the .ino file that is named exactly as the containing folder
- We should copy the entire "template" sketch folder into the new user-requested sketch folder
- In the new folder we must rename the template-main-sketch file to match the new folder name.
So let's recap with an example:
Suppose we configure the sketch template to point to/path/to/sketch/template, that has the following content:
/path/to/sketch/template/another_file.ino/path/to/sketch/template/template.ino <--- MAIN FILE/path/to/sketch/template/passwords.hif we runarduino-cli sketch new mysketchbook/newsketch, the expected result is:
./mysketchbook/newsketch/another_file.ino./mysketchbook/newsketch/newsketch.ino <--- MAIN FILE./mysketchbook/newsketch/passwords.hThe most notable part here is thattemplate.ino has been renamednewsketch.ino because it's the main file.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
gsingh93 commentedOct 19, 2023
@cmaglie thanks for the feedback! I've addressed your comments and rebased. If the template directory is If this general approach looks correct to you, I'll start working on the tests/docs when I get some time. |
cmaglie commentedOct 23, 2023
Looks good, thanks, go on! |
umbynos commentedJan 23, 2024
Hello@gsingh93 did you had time to continue? 😄 |
gsingh93 commentedJan 27, 2024
Sorry, I haven't had time to work on this in a while. Someone else can pick it up from here, or it could be closed for now and I'll reopen if I ever come back to it. Either way is fine. |
Uh oh!
There was an error while loading.Please reload this page.
Please check if the PR fulfills these requirements
Seehow to contribute
before creating one)
our contributing guidelines
UPGRADING.mdhas been updated with a migration guide (for breaking changes)configuration.schema.jsonupdated if new parameters are added.What kind of change does this PR introduce?
Implements feature request in#2239, although instead of implementing a single "blueprint" file, allows for an entire template directory.
What is the current behavior?
Running
arduino-cli sketch new MySketchwill create aMySketch/MySketch.inofile.What is the new behavior?
If
directories.templateis not set, the behavior is the same as before.If it is set, running
arduino-cli sketch new MySketchwill copy thedirectories.templatedirectory to create theMySketchdirectory.Does this PR introduce a breaking change, and istitled accordingly?
This isn't a breaking change.
Other Information
Tests/docs haven't been written. Putting this up as a draft to get initial feedback before putting in more effort. One question how to handle setting
sketchMainFilePath. Should we rename some file in the template directory toMySketch.ino? Or just pick a .ino from the directory (ideally there's only one) and return that from the RPC call?