| 
									
										
										
										
											2018-11-10 22:36:30 +05:30
										 |  |  | require "cli_parser" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-10 22:36:30 +05:30
										 |  |  |   def tap_args | 
					
						
							|  |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							|  |  |  |       usage_banner <<~EOS | 
					
						
							|  |  |  |         `tap` [<options>] <user>`/`<repo> [<URL>] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Tap a formula repository. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         List all installed taps when no arguments are passed. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         With <URL> unspecified, taps 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>. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         With <URL> specified, taps a formula repository from anywhere, using | 
					
						
							|  |  |  |         any transport protocol that `git` 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: "Use a full clone when tapping a repository. By default, the repository is "\ | 
					
						
							|  |  |  |                      "cloned as a shallow copy (`--depth=1`). To convert a shallow copy to a "\ | 
					
						
							|  |  |  |                      "full copy, you can retap passing `--full` without first untapping." | 
					
						
							|  |  |  |       switch "--force-auto-update", | 
					
						
							|  |  |  |         description: "Auto-update tap even if it is not hosted on GitHub. By default, only taps "\ | 
					
						
							|  |  |  |                      "hosted on GitHub are auto-updated (for performance reasons)." | 
					
						
							|  |  |  |       switch "--repair", | 
					
						
							|  |  |  |         description: "Migrate tapped formulae from symlink-based to directory-based structure." | 
					
						
							|  |  |  |       switch "--list-pinned", | 
					
						
							|  |  |  |         description: "List all pinned taps." | 
					
						
							|  |  |  |       switch "-q", "--quieter", | 
					
						
							|  |  |  |         description: "Suppress any warnings." | 
					
						
							|  |  |  |       switch :debug | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-02 20:28:54 +00:00
										 |  |  |   def tap | 
					
						
							| 
									
										
										
										
											2018-11-10 22:36:30 +05:30
										 |  |  |     tap_args.parse | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if args.repair? | 
					
						
							| 
									
										
										
										
											2016-09-30 18:22:53 -05:00
										 |  |  |       Tap.each(&:link_completions_and_manpages) | 
					
						
							| 
									
										
										
										
											2018-11-10 22:36:30 +05:30
										 |  |  |     elsif args.list_pinned? | 
					
						
							| 
									
										
										
										
											2015-08-21 12:33:33 +08:00
										 |  |  |       puts Tap.select(&:pinned?).map(&:name) | 
					
						
							| 
									
										
										
										
											2015-12-26 13:01:52 +08:00
										 |  |  |     elsif ARGV.named.empty? | 
					
						
							|  |  |  |       puts Tap.names | 
					
						
							| 
									
										
										
										
											2012-03-02 20:28:54 +00:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2018-09-17 19:44:12 +02:00
										 |  |  |       tap = Tap.fetch(ARGV.named.first) | 
					
						
							| 
									
										
										
										
											2015-11-10 18:33:57 +08:00
										 |  |  |       begin | 
					
						
							| 
									
										
										
										
											2018-11-02 17:18:07 +00:00
										 |  |  |         tap.install clone_target:      ARGV.named.second, | 
					
						
							| 
									
										
										
										
											2018-04-12 16:14:02 -07:00
										 |  |  |                     force_auto_update: force_auto_update?, | 
					
						
							| 
									
										
										
										
											2018-11-02 17:18:07 +00:00
										 |  |  |                     full_clone:        full_clone?, | 
					
						
							| 
									
										
										
										
											2018-11-10 22:36:30 +05:30
										 |  |  |                     quiet:             args.quieter? | 
					
						
							| 
									
										
										
										
											2016-04-04 03:18:55 -07:00
										 |  |  |       rescue TapRemoteMismatchError => e | 
					
						
							|  |  |  |         odie e | 
					
						
							| 
									
										
										
										
											2017-10-07 00:31:28 +02:00
										 |  |  |       rescue TapAlreadyTappedError, TapAlreadyUnshallowError # rubocop:disable Lint/HandleExceptions | 
					
						
							| 
									
										
										
										
											2015-11-10 09:12:25 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2012-03-02 20:28:54 +00:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-30 17:01:36 +01:00
										 |  |  |   def full_clone? | 
					
						
							| 
									
										
										
										
											2018-11-10 22:36:30 +05:30
										 |  |  |     args.full? || ARGV.homebrew_developer? | 
					
						
							| 
									
										
										
										
											2016-05-30 17:01:36 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2018-04-12 16:14:02 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def force_auto_update? | 
					
						
							|  |  |  |     # if no relevant flag is present, return nil, meaning "no change" | 
					
						
							| 
									
										
										
										
											2018-11-10 22:36:30 +05:30
										 |  |  |     true if args.force_auto_update? | 
					
						
							| 
									
										
										
										
											2018-04-12 16:14:02 -07:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2012-03-16 12:49:09 +00:00
										 |  |  | end |