| 
									
										
										
										
											2025-03-14 16:53:07 +00:00
										 |  |  | # typed: true # rubocop:todo Sorbet/StrictSigil | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-13 14:50:03 +00:00
										 |  |  | require "services/formula_wrapper" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-14 04:35:30 +00:00
										 |  |  | module Homebrew | 
					
						
							|  |  |  |   module Services | 
					
						
							|  |  |  |     module Formulae | 
					
						
							|  |  |  |       # All available services, with optional filters applied | 
					
						
							|  |  |  |       # @private | 
					
						
							|  |  |  |       sig { params(loaded: T.nilable(T::Boolean), skip_root: T::Boolean).returns(T::Array[Services::FormulaWrapper]) } | 
					
						
							|  |  |  |       def self.available_services(loaded: nil, skip_root: false) | 
					
						
							|  |  |  |         require "formula" | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-14 04:35:30 +00:00
										 |  |  |         formulae = Formula.installed | 
					
						
							|  |  |  |                           .map { |formula| FormulaWrapper.new(formula) } | 
					
						
							|  |  |  |                           .select(&:service?) | 
					
						
							|  |  |  |                           .sort_by(&:name) | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-14 04:35:30 +00:00
										 |  |  |         formulae = formulae.select { |formula| formula.loaded? == loaded } unless loaded.nil? | 
					
						
							|  |  |  |         formulae = formulae.reject { |formula| formula.owner == "root" } if skip_root | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-14 04:35:30 +00:00
										 |  |  |         formulae | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-14 04:35:30 +00:00
										 |  |  |       # List all available services with status, user, and path to the file. | 
					
						
							|  |  |  |       def self.services_list | 
					
						
							|  |  |  |         available_services.map(&:to_hash) | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2025-02-26 13:26:37 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |