Arduino CLI: An introduction
It’s been a long time since we first launched our Arduino IDE inspired by the glorious Processing interface, and what started as a Java UI wrapper for build scripts has gone through countless iterations over the past fifteen years.
Some may remember the transition between 1.0 and 1.5, or the application’s icon being replaced, but behind the scenes where many of our users don’t go look, we’ve completely overhauled the way libraries are included, code is cleaned, fail-safe measures are implemented, and a sketch is built.
At the same time our more advanced users have been implementing workarounds to use our internal builder command in their workflows for the most diverse reasons.
Projects have spawned to create Arduino-based makefiles, build scripts, code linters ,and snippets to program their boards using their favorite code editors, and we’ve seen people use Eclipse, Sublime Text, VS Code, Vi(m), Emacs, or even XCode to create Arduino projects.
We keep our eyes peeled when it comes to how our community uses our tools and try as much as possible to learn from it, and this inspired us to get back to the drawing board.
The software that makes up the Arduino platform has grown incrementally over time — new features were added and sometimes the need to quickly factor in those changes did not make it easy to foresee how things would develop years ahead. This led to a situation in which multiple chunks of code and functionalities were spread across different Arduino software products (the Java IDE, the Create Agent, the Web Editor servers, upload/discovery tools, etc.), some of them overlapping or redundant.
The needs of our community, as well as our own, prompted us to radically rethink our approach and embark on a major refactoring operation with the goal to obtain a single reference implementation: the Arduino Command Line Interface.
As we move forward, all our legacy products are being reworked to use the Arduino CLI as the foundation to build upon.
We believe this effort will provide our users and ourselves with more advanced, flexible tools that we can all benefit from.
How it started
Following an extended period of internal use and exploration, we announced the Arduino CLI alpha preview in August 2018.
From that moment on we concentrated our efforts into adding features, smoothing out some edges, and improving the CLI usability, largely based on users’ feedback from within our community (check out our latest release on GitHub).
A tool to enable advanced workflows
Having a flexible yet simple command line tool providing all the features and flexibility that made Arduino a successful platform can enable users to find new ways of improving their productivity. A great example is how Arduino CLI has been used in Continuous Integration processes, a great example of which came from our friends at TensorFlow, a popular open source machine learning framework. This encouraged us to provide an official Arduino CLI GitHub Action.
This application demonstrates how the Arduino CLI is not just a command line tool, but contains all you need to easily build applications around the Arduino ecosystem. Parse the JSON output of the CLI or implement it as an always-on service that accepts commands via a gRPC interface using your language of choice.
We use gRPC in our Pro IDE and in recent releases of our classic Java IDE.
If you like, you can even use it in your Go application as a library. Our Web Editor services are built using this approach.
How it works
Arduino CLI allows you to replicate the same workflows you are used to with our IDE by using simple commands in a shell, your CI workflow, or wherever you see fit:
1. Install the board package and your favorite libraries on your PC.
2. Create a sketch using your favorite editor.
3. Compile and upload the sketch to your board.
We’re soon going to release our CLI primer to get you all onboard. Check out the trailer below for a sneak peek!