Forked from onewheelskyward/generate-hombrew-install-commands.rb
Last active
December 27, 2015 16:29
-
-
Save kgust/7355214 to your computer and use it in GitHub Desktop.
Generate Homebrew Install Commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| brews = [] | |
| out = IO.popen("brew leaves", "r") do |io| | |
| brews = io.read.split "\n" | |
| end | |
| def parse(brew, brew_info) | |
| in_options = false | |
| print "brew reinstall -v #{brew} " | |
| brew_info.split("\n").each do |m| | |
| #puts m.inspect | |
| if in_options | |
| m.scan(/(--[a-zA-Z-]+)/).each do |x| | |
| print x[0] + " " | |
| end | |
| #puts matchdata.inspect | |
| in_options = false | |
| end | |
| if /\*$/.match m | |
| in_options = true | |
| end | |
| end | |
| puts | |
| end | |
| brews.each do |brew| | |
| #puts "brew info #{brew}" | |
| IO.popen("brew info #{brew}", "r") do |info| | |
| parse(brew, info.read) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment