@@ -24,13 +24,15 @@ def autolocate!
24
24
attr_accessor :installation
25
25
attr_reader :prefs_cache
26
26
attr_reader :prefs_response_time
27
+ attr_reader :library_is_indexed
27
28
28
29
# @param installation [ArduinoInstallation] the location of the Arduino program installation
29
30
def initialize ( installation )
30
31
@display_mgr = DisplayManager ::instance
31
32
@installation = installation
32
33
@prefs_response_time = nil
33
34
@prefs_cache = prefs
35
+ @library_is_indexed = false
34
36
end
35
37
36
38
# fetch preferences to a hash
@@ -95,8 +97,31 @@ def run_and_capture(*args)
95
97
{ out : str_out , err : str_err , success : success }
96
98
end
97
99
98
- def board_installed? ( board )
99
- run_with_gui_guess ( " about board not installed" , "--board" , board )
100
+ def board_installed? ( boardname )
101
+ run_with_gui_guess ( " about board not installed" , "--board" , boardname )
102
+ end
103
+
104
+ # install a board by name
105
+ # @param name [String] the board name
106
+ # @return [bool] whether the command succeeded
107
+ def install_board ( boardname )
108
+ run ( "--install_boards" , boardname )
109
+ end
110
+
111
+ # install a library by name
112
+ # @param name [String] the library name
113
+ # @return [bool] whether the command succeeded
114
+ def install_library ( library_name )
115
+ result = run ( "--install_library" , library_name )
116
+ @library_is_indexed = true if result
117
+ result
118
+ end
119
+
120
+ # update the library index
121
+ def update_library_index
122
+ # install random lib so the arduino IDE grabs a new library index
123
+ # see: https://github.com/arduino/Arduino/issues/3535
124
+ install_library ( "USBHost" )
100
125
end
101
126
102
127
end
0 commit comments