酿造公式安装选项

Brew formulae install options

我正在尝试为 Brew 编写公式,允许用户 opt-in/opt-out 正在安装的工具的某些功能。我找不到任何可能的文档。

更具体地说,我想为开发人员提供选择退出崩溃报告的选项,然后公式可以决定使用哪个来源或类似的东西。

Formula Cookbook ¶ Adding optional steps 可能对您有帮助:

If you want to add an option:

class Yourformula < Formula
  ...
  option "with-ham", "Description of the option"
  option "without-spam", "Another description"

  depends_on "foo" => :optional  # will automatically add a with-foo option
  ...

And then to define the effects the options have:

if build.with? "ham"
  # note, no "with" in the option name (it is added by the build.with? method)
end

if build.without? "ham"
  # works as you'd expect. True if `--without-ham` was given.
end