noopkat / avrgirl-arduino

:girl: :pager: A NodeJS library for flashing compiled sketch files to Arduino microcontroller boards.
MIT License
506 stars 129 forks source link

Adding support for custom boards in the cli #183

Closed JordiChauzi closed 4 years ago

JordiChauzi commented 4 years ago

Fixes #97

This PR allows to provide a custom board specification in the CLI, eg:

avrgirl-arduino flash -f Blink.cpp.hex -a custom.json

This change being in the CLI part, I am not sure what is the appropriate way to test it.

There is currently not a lot of documentation for custom boards (looking at you #151), so I did not add documentation on the expected JSON format. The only tricky part, I think, is the signature field where we create the Buffer from the input JSON array. Maybe adding a CLI option to display the JSON specification for a supported board may help ?

Maybe we want to the feature to the library part? It may make sense to handle the Buffer creation for the user.

I tried to provide an accurate error message, but using the same argument, it is kind of hard to discriminate between a board name and a JSON file.

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.8%) to 45.357% when pulling 0c9488078d3c352729c9b13a85e7e6cb5f6efcf3 on JordiChauzi:cli-custom-board into 6ed8d2579c968e9bbb41f911e1d347b878be7160 on noopkat:master.

noopkat commented 4 years ago

hey @JordiChauzi this new feature is awesome and I love the code and error messages!

I think you were right to point out the issue of the board spec technically being invalid JSON. What I'm going to propose is to switch to a .js file instead, and document (in the README) the general idea of how to create this file. We can point the user to the custom board section of the README rather than reinvent the wheel so they can learn how to do this. What do you think?

JordiChauzi commented 4 years ago

hey @JordiChauzi this new feature is awesome and I love the code and error messages!

I think you were right to point out the issue of the board spec technically being invalid JSON. What I'm going to propose is to switch to a .js file instead, and document (in the README) the general idea of how to create this file. We can point the user to the custom board section of the README rather than reinvent the wheel so they can learn how to do this. What do you think?

Yep, this seems logical. I have changed the custom file to a JavaScript file. I have implemented a simple solution to export the board (ie. module.exports = board;). Tell me if you want something different!

JordiChauzi commented 4 years ago

thanks for making these changes! I'm ready to merge and release these changes if you're comfortable with that!

All is good on my side!

noopkat commented 4 years ago

whoops! Sorry for dropping the ball on this! Merging and releasing in a new version now 👀 Thanks again for adding this much needed feature 😄 🎉

bitmoji