Kicad-cli issues

I was playing a bit with the new kicad-cli

I saw some issues that could be improved.

When the sch is exported as svg I can specify a folder to put the file inside with -o flag, but not the file_path. Also if the schematic has multiple pages, it exports all of them inside of that folder if the -o flag is passed or in the current folder if it is not.

The flag -o could specify the filename if a single .kicad_sch is passed and export just that file. it could export all the pages at once as it is doing if .kicad_pro is passed instead. In the latter case, the -o can set the dir_path as it is doing

It would be nice to have the option to list schematic pages. Maybe something like kicad-cli sch pages

A similar thing happens when exporting pcb layers to svg. I have to specify which layer I am exporting… most of the time people would like to export all layers in different files. For that, a flag to set the prefix of the filename would be nice, and then the layer name or id could be added to the filename

Also, a way to list the used layers would be nice to have. Something like kicad-cli pcb layers

Also, why do we need a separated kicad-cli instead of just using kicad? If you pass the command line flags like pcb/sch then it should run the command line actions and then exit.

I reported the first part as kicad-cli creates new directory for output rather than changing output file name (#13647) · Issues · KiCad / KiCad Source Code / kicad · GitLab and I think this has just been fixed here.

Agree that the additional outputs would be very useful.

1 Like

No, the kicad internals load the project file automatically if the schematic file is passed. In fact the project file sometimes contains useful settings like the worksheet selection which is somewhat annoying. I’m not going to make it fight that implementation which will only result in more forum posts.

I wanted to add more things, but it will have to wait for v8.
I also want to review potential file format output options, i.e. output the list in json and plaintext

Covered many times on the forum.

Windows does not support dual mode executables. A GUI capable executable is marked in the binary as such, when a GUI app is run from console, it immediately gets reparented away from the console, the console cannot wait for the gui app to complete nor redirect output directly.

Also the standalone executables are probably getting dropped in v8 due to Apple packaging lockdowns. The standard kicad args will be used to allow directly launching the subfunctions as you can now.

There’s also a large framework issue because a GUI based wxWidgets app even on Linux immediately and early initializes GTK. This results in a crash on headless linux systems :wink:

1 Like

The first part about the schematics is an issue. Right now the -o flag it doesn’t set the output file but the output directory. If the project has more than one schematic page it will export all of them at once. This is good but being able to export a single one and setting it’s name it also desirable.

For layout, it works the opposite. It exports a single file that can be composed with multiple layers. But it could also have a single way of exporting all the existing layers each one on its own file.

The current version of the pcb export requires the layer name, so the list layers within the file is a must. And please, always do the the plain text version first.

Yea that’s a bit tricky because you can’t export pages by feeding it a specific kicad_sch. Due to how hierarchical schematics work, you must always load the root schematic. Simply put, in v8, the text for -o is being fixed to “output directory”, due to dev policies it can’t be fixed for v7. Maybe a page number string filter an be added but the root schematic must always be fed for it to make sense.

Anyway, no further changes are happening for v7.

You can pass 2 files then, the main sch and the page you want to export.