| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  | require "abstract_command" | 
					
						
							| 
									
										
										
										
											2024-07-14 19:23:21 -07:00
										 |  |  | require "tap" | 
					
						
							| 
									
										
										
										
											2018-11-10 22:36:30 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  |   module Cmd | 
					
						
							|  |  |  |     class TapCmd < AbstractCommand | 
					
						
							|  |  |  |       cmd_args do | 
					
						
							|  |  |  |         usage_banner "`tap` [<options>] [<user>`/`<repo>] [<URL>]" | 
					
						
							|  |  |  |         description <<~EOS | 
					
						
							|  |  |  |           Tap a formula repository. | 
					
						
							|  |  |  |           If no arguments are provided, list all installed taps. | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  |           With <URL> unspecified, tap a formula repository from GitHub using HTTPS. | 
					
						
							|  |  |  |           Since so many taps are hosted on GitHub, this command is a shortcut for | 
					
						
							|  |  |  |           `brew tap` <user>`/`<repo> `https://github.com/`<user>`/homebrew-`<repo>. | 
					
						
							| 
									
										
										
										
											2018-11-10 22:36:30 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  |           With <URL> specified, tap a formula repository from anywhere, using | 
					
						
							|  |  |  |           any transport protocol that `git`(1) handles. The one-argument form of `tap` | 
					
						
							|  |  |  |           simplifies but also limits. This two-argument command makes no | 
					
						
							|  |  |  |           assumptions, so taps can be cloned from places other than GitHub and | 
					
						
							|  |  |  |           using protocols other than HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync. | 
					
						
							|  |  |  |         EOS | 
					
						
							|  |  |  |         switch "--full", | 
					
						
							|  |  |  |                description: "Convert a shallow clone to a full clone without untapping. Taps are only cloned as " \ | 
					
						
							|  |  |  |                             "shallow clones if `--shallow` was originally passed.", | 
					
						
							|  |  |  |                replacement: false, | 
					
						
							|  |  |  |                disable:     true | 
					
						
							|  |  |  |         switch "--shallow", | 
					
						
							|  |  |  |                description: "Fetch tap as a shallow clone rather than a full clone. Useful for continuous " \ | 
					
						
							|  |  |  |                             "integration.", | 
					
						
							|  |  |  |                replacement: false, | 
					
						
							|  |  |  |                disable:     true | 
					
						
							|  |  |  |         switch "--[no-]force-auto-update", | 
					
						
							|  |  |  |                hidden: true | 
					
						
							|  |  |  |         switch "--custom-remote", | 
					
						
							|  |  |  |                description: "Install or change a tap with a custom remote. Useful for mirrors." | 
					
						
							|  |  |  |         switch "--repair", | 
					
						
							| 
									
										
										
										
											2025-02-01 00:45:16 -05:00
										 |  |  |                description: "Add missing symlinks to tap manpages and shell completions. Correct git remote " \ | 
					
						
							|  |  |  |                             "refs for any taps where upstream HEAD branch has been renamed." | 
					
						
							| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  |         switch "--eval-all", | 
					
						
							|  |  |  |                description: "Evaluate all the formulae, casks and aliases in the new tap to check validity. " \ | 
					
						
							| 
									
										
										
										
											2025-01-27 14:21:27 +00:00
										 |  |  |                             "Implied if `$HOMEBREW_EVAL_ALL` is set." | 
					
						
							| 
									
										
										
										
											2024-12-21 22:51:47 -05:00
										 |  |  |         switch "-f", "--force", | 
					
						
							| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  |                description: "Force install core taps even under API mode." | 
					
						
							| 
									
										
										
										
											2018-11-10 22:36:30 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  |         named_args :tap, max: 2
 | 
					
						
							| 
									
										
										
										
											2024-02-20 15:10:26 +01:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       sig { override.void } | 
					
						
							|  |  |  |       def run | 
					
						
							|  |  |  |         if args.repair? | 
					
						
							|  |  |  |           Tap.installed.each do |tap| | 
					
						
							|  |  |  |             tap.link_completions_and_manpages | 
					
						
							|  |  |  |             tap.fix_remote_configuration | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |         elsif args.no_named? | 
					
						
							|  |  |  |           puts Tap.installed.sort_by(&:name) | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           begin | 
					
						
							| 
									
										
										
										
											2025-03-05 17:31:25 +08:00
										 |  |  |             tap = Tap.fetch(args.named.fetch(0)) | 
					
						
							| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  |             tap.install clone_target:  args.named.second, | 
					
						
							|  |  |  |                         custom_remote: args.custom_remote?, | 
					
						
							|  |  |  |                         quiet:         args.quiet?, | 
					
						
							|  |  |  |                         verify:        args.eval_all? || Homebrew::EnvConfig.eval_all?, | 
					
						
							|  |  |  |                         force:         args.force? | 
					
						
							| 
									
										
										
										
											2025-03-05 17:31:25 +08:00
										 |  |  |           rescue Tap::InvalidNameError, TapRemoteMismatchError, TapNoCustomRemoteError => e | 
					
						
							| 
									
										
										
										
											2024-04-01 11:42:17 -07:00
										 |  |  |             odie e | 
					
						
							|  |  |  |           rescue TapAlreadyTappedError | 
					
						
							|  |  |  |             nil | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2015-11-10 09:12:25 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2012-03-02 20:28:54 +00:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2012-03-16 12:49:09 +00:00
										 |  |  | end |