Add basic JSON option to brew cask
$ brew cask info --json <cask>
This commit is contained in:
		
							parent
							
								
									61a8c4d1fb
								
							
						
					
					
						commit
						2d5ae645d9
					
				@ -129,5 +129,26 @@ module Hbc
 | 
				
			|||||||
        odebug "Cask instance method '#{method}':", send(method).to_yaml
 | 
					        odebug "Cask instance method '#{method}':", send(method).to_yaml
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def to_hash
 | 
				
			||||||
 | 
					      hsh = {
 | 
				
			||||||
 | 
					        "name" => name,
 | 
				
			||||||
 | 
					        "homepage" => homepage,
 | 
				
			||||||
 | 
					        "url" => url,
 | 
				
			||||||
 | 
					        "appcast" => appcast,
 | 
				
			||||||
 | 
					        "version" => version,
 | 
				
			||||||
 | 
					        "sha256" => sha256,
 | 
				
			||||||
 | 
					        "artifacts" => artifacts,
 | 
				
			||||||
 | 
					        "caveats" => caveats,
 | 
				
			||||||
 | 
					        "depends_on" => depends_on,
 | 
				
			||||||
 | 
					        "conflicts_with" => conflicts_with,
 | 
				
			||||||
 | 
					        "container" => container,
 | 
				
			||||||
 | 
					        "gpg" => gpg,
 | 
				
			||||||
 | 
					        "accessibility_access" => accessibility_access,
 | 
				
			||||||
 | 
					        "auto_updates" => auto_updates
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      hsh
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -1,15 +1,24 @@
 | 
				
			|||||||
 | 
					require "json"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module Hbc
 | 
					module Hbc
 | 
				
			||||||
  class CLI
 | 
					  class CLI
 | 
				
			||||||
    class Info < AbstractCommand
 | 
					    class Info < AbstractCommand
 | 
				
			||||||
 | 
					      option "--json", :json, false
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      def initialize(*)
 | 
					      def initialize(*)
 | 
				
			||||||
        super
 | 
					        super
 | 
				
			||||||
        raise CaskUnspecifiedError if args.empty?
 | 
					        raise CaskUnspecifiedError if args.empty?
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      def run
 | 
					      def run
 | 
				
			||||||
        casks.each do |cask|
 | 
					        if json?
 | 
				
			||||||
          odebug "Getting info for Cask #{cask}"
 | 
					          json = casks.map(&:to_hash)
 | 
				
			||||||
          self.class.info(cask)
 | 
					          puts JSON.generate(json)
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          casks.each do |cask|
 | 
				
			||||||
 | 
					            odebug "Getting info for Cask #{cask}"
 | 
				
			||||||
 | 
					            self.class.info(cask)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user