-
-
Notifications
You must be signed in to change notification settings - Fork 371
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable creating new sketches from a template directory #2359
base: master
Are you sure you want to change the base?
Conversation
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
- The main 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.h
if we run arduino-cli sketch new mysketchbook/newsketch
, the expected result is:
./mysketchbook/newsketch/another_file.ino
./mysketchbook/newsketch/newsketch.ino <--- MAIN FILE
./mysketchbook/newsketch/passwords.h
The most notable part here is that template.ino
has been renamed newsketch.ino
because it's the main file.
@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. |
Looks good, thanks, go on! |
Hello @gsingh93 did you had time to continue? 😄 |
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. |
Please check if the PR fulfills these requirements
See how to contribute
before creating one)
our contributing guidelines
UPGRADING.md
has been updated with a migration guide (for breaking changes)configuration.schema.json
updated 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 MySketch
will create aMySketch/MySketch.ino
file.What is the new behavior?
If
directories.template
is not set, the behavior is the same as before.If it is set, running
arduino-cli sketch new MySketch
will copy thedirectories.template
directory to create theMySketch
directory.Does this PR introduce a breaking change, and is titled 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?