| 
									
										
										
										
											2024-03-21 10:22:45 -07:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2021-05-03 20:42:35 +05:30
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 10:22:45 -07:00
										 |  |  | require "abstract_command" | 
					
						
							| 
									
										
										
										
											2021-05-03 20:42:35 +05:30
										 |  |  | require "formula" | 
					
						
							|  |  |  | require "completions" | 
					
						
							| 
									
										
										
										
											2022-11-08 20:33:30 +09:00
										 |  |  | require "manpages" | 
					
						
							| 
									
										
										
										
											2024-01-31 20:00:54 -08:00
										 |  |  | require "system_command" | 
					
						
							| 
									
										
										
										
											2021-05-03 20:42:35 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2024-03-21 10:22:45 -07:00
										 |  |  |   module DevCmd | 
					
						
							|  |  |  |     class GenerateManCompletions < AbstractCommand | 
					
						
							|  |  |  |       include SystemCommand::Mixin | 
					
						
							| 
									
										
										
										
											2024-03-21 10:25:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 10:22:45 -07:00
										 |  |  |       cmd_args do | 
					
						
							|  |  |  |         description <<~EOS | 
					
						
							|  |  |  |           Generate Homebrew's manpages and shell completions. | 
					
						
							|  |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2025-06-03 13:01:49 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 10:22:45 -07:00
										 |  |  |         named_args :none | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2021-05-03 20:42:35 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 10:22:45 -07:00
										 |  |  |       sig { override.void } | 
					
						
							|  |  |  |       def run | 
					
						
							| 
									
										
										
										
											2024-04-30 10:39:35 +01:00
										 |  |  |         Homebrew.install_bundler_gems!(groups: ["man"]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 10:22:45 -07:00
										 |  |  |         Commands.rebuild_internal_commands_completion_list | 
					
						
							|  |  |  |         Manpages.regenerate_man_pages(quiet: args.quiet?) | 
					
						
							|  |  |  |         Completions.update_shell_completions! | 
					
						
							| 
									
										
										
										
											2021-05-03 20:42:35 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 10:22:45 -07:00
										 |  |  |         diff = system_command "git", args: [ | 
					
						
							| 
									
										
										
										
											2024-12-02 15:36:00 -05:00
										 |  |  |           "-C", HOMEBREW_REPOSITORY, | 
					
						
							|  |  |  |           "diff", "--shortstat", "--patch", "--exit-code", "docs/Manpage.md", "manpages", "completions" | 
					
						
							| 
									
										
										
										
											2024-03-21 10:22:45 -07:00
										 |  |  |         ] | 
					
						
							|  |  |  |         if diff.status.success? | 
					
						
							|  |  |  |           ofail "No changes to manpage or completions." | 
					
						
							| 
									
										
										
										
											2024-12-02 15:36:00 -05:00
										 |  |  |         elsif /1 file changed, 1 insertion\(\+\), 1 deletion\(-\).*-\.TH "BREW" "1" "\w+ \d+"/m.match?(diff.stdout) | 
					
						
							|  |  |  |           ofail "No changes to manpage or completions other than the date." | 
					
						
							| 
									
										
										
										
											2024-03-21 10:22:45 -07:00
										 |  |  |         else | 
					
						
							|  |  |  |           puts "Manpage and completions updated." | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2022-09-02 08:24:33 +01:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2021-05-03 20:42:35 +05:30
										 |  |  |   end | 
					
						
							|  |  |  | end |