arduino / arduino-cli

Arduino command line tool
https://arduino.github.io/arduino-cli/latest/
GNU General Public License v3.0
4.35k stars 378 forks source link

Add `providesIncludes` field to library search scope #1893

Closed per1234 closed 2 years ago

per1234 commented 2 years ago

Describe the request

Add the providesIncludes field of the library index to the search scope of the arduino-cli lib search command.

🙂 The chances of finding a library by searching for its header filename will be increased.

$ arduino-cli lib search painlessMesh
Downloading index: library_index.json.gz downloaded
Downloading index signature: library_index.json.sig downloaded
Name: "Painless Mesh"
  Author: Coopdis,Scotty Franzyshen,Edwin van Leeuwen,Germán Martín,Maximilian Schwarz,Doanh Doanh
  Maintainer: Edwin van Leeuwen
  Sentence: A painless way to setup a mesh with ESP8266 and ESP32 devices
  Paragraph: A painless way to setup a mesh with ESP8266 and ESP32 devices
  Website: https://gitlab.com/painlessMesh/painlessMesh
  Category: Communication
  Architecture: esp8266, esp32
  Types: Contributed
  Versions: [0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.2.0, 0.2.1, 0.5.0, 0.5.4, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.5, 0.7.0, 1.0.0, 1.0.2, 1.0.3, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7, 1.2.8, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.5.0]
  Provides includes: painlessMesh.h
  Dependencies: ArduinoJson, TaskScheduler

Describe the current behavior

The scope of arduino-cli lib search is the following fields of the library index:

https://github.com/arduino/arduino-cli/blob/5730e2ebbed39452a3a0517bb3571a1b94d864f7/commands/lib/search.go#L44

The scope of the search in Arduino IDE 1.x is the following fields of the library index:

https://github.com/arduino/Arduino/blob/1.8.19/app/src/cc/arduino/contributions/libraries/ui/LibrariesIndexTableModel.java#L147-L153

Often when searching for a dependency of someone's code the only information the user has is the #include directive for the missing file and so that filename is the logical term to use in a lib search query. That filename is not necessarily present in the fields currently used by lib search.

The includes field of the library.properties metadata file of Arduino libraries contains a list of the names of the library's header files which should be added in #include directives to a sketch when the library is selected from the Arduino IDE's Sketch > Include library menu. This list is the source of the elements of the providesIncludes array field of the library index. For this reason, the providesIncludes field is the source of highly relevant text for searches.

🙁 It is sometimes difficult to find a dependency when the user only knows the header filename.

$ arduino-cli version
arduino-cli.exe  Version: git-snapshot Commit: 5730e2eb Date: 2022-09-24T17:05:10Z

$ arduino-cli lib search painlessMesh
Downloading index: library_index.json.gz downloaded
Downloading index signature: library_index.json.sig downloaded
No libraries matching your search.

Arduino CLI version

5730e2eb

Operating system

Windows

Operating system version

10

Additional context

Example of a user who would have benefited from this: https://github.com/arduino/arduino-cli/issues/107#issuecomment-814278260


Feature request for Arduino IDE 1.x: https://github.com/arduino/Arduino/issues/7604

Arduino IDE 1.x implementation: https://github.com/arduino/Arduino/commit/60021c1e6394e20b33c58a587141eb86c11db5c9

Issue checklist

cmaglie commented 2 years ago

Fixed by #1896