Ok so trying to get started with the cli tools and it has an annoying behavior I hope to change or circumvent.
./arduino-cli sketch new
This then creates a new directory that has the .ino file in it. So as you can imagine that after creating several new sketches I am going to quickly have a directory filed with many directories all containing a sketch. I am not sure who thought this would be appropriate to begin with but whatever...Anyways.
I would be open to the either have a directory called SketchBook and any new .ino files can be placed in there when I invoke the sketch new command. Or just create the filename.ino without any directory and I will place it as needed.
But for it to create a entirely new directory every time for every new sketch is just duplicitous, redundant and annoying.
The directory is the sketch. Because many Arduino sketches consist of a single .ino file, it's easy to assume that the file is the sketch, but this is not correct. A sketch may consist of many files (even hundreds in the case of complex sketches like Marlin).
Why is that a bad thing? A directory is a very convenient container for all the files associated with a project. Even if you only have a single .ino file, you might want to add documentation or other assets. And once you start using formal version control, you will find that it's necessary anyway because the repository is a directory.
Hmm, interesting. I will be honest I am somewhat new to programming but I have played with python and C and I had not encountered keeping separate directories for each program as default behavior. So to me it just seemed like it would create excess clutter having many multiple directories all containing a single sketch.
Still getting used to this whole Arduino ecosystem. I am just used to a simpler experience but again just getting started..
If I create/edit a program in python or C I am not editing a directory so I am not understanding how you are saying the directory IS the sketch? The sketch is a .ino file, that is all. Yes at some point you might want to create a directory for it to house drivers, libraries, documentation etc.... But automatically creating a directory for every basic sketch should not be the default behavior.
Also perhaps I am simply not grasping the concept of what a sketch is. I will browse the fundamentals section and see if I can find some enlightenment.
Also I appreciate your engagement and I apologize if I seem like I am being difficult, just trying to understand the concepts behind the operations.
When the time comes that you want to organize a Python or C program into multiple files, you'll find that some special syntax/compiler flags/metadata files are needed. But with Arduino, you only need to add another tab to your sketch and everything just works.
Multiple tabs really helps to navigate through a more advanced sketch rather than constantly scrolling up and down through thousands of lines to find the code you're looking for in a single huge file.
If so, then a million 3D printer users will be quite surprised to learn that their firmware is only a single comment:
I found the following compromise, you can direct the sketch creation to a directory of your choosing.
./arduino-cli sketch new Sketch_Book/testsketch
This will create a directory /testsketch within a parent directory /Sketch_Book so this way all the sketch directories are housed in a common location. /Arduino/Sketch_Book
That's definitely the way to go. The Arduino IDE even has formal support for this "sketchbook" concept, where all your sketch folders are stored under a single parent directory. You are welcome to store sketches anywhere, but the ones in the sketchbook are easily accessible via the IDE's File > Sketchbook menu.
It even goes one step farther by using the sketchbook folder to store various other assets in subfolders of the sketchbook:
hardware - manually installed boards platforms
libraries - user installed libraries
theme - custom themes for the classic IDE
tools - plugins for the classic IDE
Of course, since it's not a GUI, much of that doesn't apply to Arduino CLI, so it doesn't have so much of a focus on the "sketchbook" concept, but it does have an equivalent for the non-GUI aspects, which is set via the directories.user configuration, and you might find it convenient to store your sketches there.