Passing Options to Homebrew Formula
Arunvel Sriram
1 min read
Homebrew Formula can receive options via command-line arguments.
Wanted to compile and install code from a private repo and Devs may use ssh
or https
in their local machines. So added an option to toggle the url/remote:
# Formula/infractl.rb
class Infractl < Formula
desc "infrastructure management tool"
option "with-https-remote", "Use https remote instead of ssh remote when cloning infractl repository"
url "git@gitlab.com:path/to/myrepo.git", :using => :git, :branch => "main"
version "main"
if build.with? "https-remote"
url "https://gitlab.com/path/to/myrepo.git", :using => :git, :branch => "main"
end
depends_on "go" => :build
def install
system "make", "build/infractl"
bin.install "out/infractl"
end
end
During installation we can do brew install --with-https-remote tap-name/infractl
to use the https remote.
Also, brew options <formula>
and brew install <formula> -h
lists all available options for the formula.
0
Subscribe to my newsletter
Read articles from Arunvel Sriram directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Arunvel Sriram
Arunvel Sriram
Software Engineer | Polyglot | DevOps | Open Source