| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  | module Hbc | 
					
						
							|  |  |  |   class CLI | 
					
						
							|  |  |  |     class InternalDump < InternalUseBase | 
					
						
							|  |  |  |       def self.run(*arguments) | 
					
						
							|  |  |  |         cask_tokens = cask_tokens_from(arguments) | 
					
						
							|  |  |  |         raise CaskUnspecifiedError if cask_tokens.empty? | 
					
						
							|  |  |  |         retval = dump_casks(*cask_tokens) | 
					
						
							|  |  |  |         # retval is ternary: true/false/nil | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |         raise CaskError, "nothing to dump" if retval.nil? | 
					
						
							|  |  |  |         raise CaskError, "dump incomplete" unless retval | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def self.dump_casks(*cask_tokens) | 
					
						
							| 
									
										
										
										
											2017-03-06 20:37:13 +01:00
										 |  |  |         CLI.debug = true # Yuck. At the moment this is the only way to make dumps visible | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |         count = 0
 | 
					
						
							|  |  |  |         cask_tokens.each do |cask_token| | 
					
						
							|  |  |  |           begin | 
					
						
							| 
									
										
										
										
											2017-03-13 01:09:36 +01:00
										 |  |  |             cask = CaskLoader.load(cask_token) | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |             count += 1
 | 
					
						
							|  |  |  |             cask.dumpcask | 
					
						
							|  |  |  |           rescue StandardError => e | 
					
						
							|  |  |  |             opoo "#{cask_token} was not found or would not load: #{e}" | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |         count.zero? ? nil : count == cask_tokens.length | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def self.help | 
					
						
							| 
									
										
										
										
											2017-01-23 01:16:07 +00:00
										 |  |  |         "dump the given Cask in YAML format" | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | end |