diff --git a/Library/Homebrew/cask/cmd.rb b/Library/Homebrew/cask/cmd.rb index 5ef9a9f634..fde3f0cf9a 100644 --- a/Library/Homebrew/cask/cmd.rb +++ b/Library/Homebrew/cask/cmd.rb @@ -79,6 +79,70 @@ module Cask EOS end + OPTIONS = [ + [:flag, "--appdir=", { + description: "Target location for Applications. " \ + "Default: `#{Config::DEFAULT_DIRS[:appdir]}`", + }], + [:flag, "--colorpickerdir=", { + description: "Target location for Color Pickers. " \ + "Default: `#{Config::DEFAULT_DIRS[:colorpickerdir]}`", + }], + [:flag, "--prefpanedir=", { + description: "Target location for Preference Panes. " \ + "Default: `#{Config::DEFAULT_DIRS[:prefpanedir]}`", + }], + [:flag, "--qlplugindir=", { + description: "Target location for QuickLook Plugins. " \ + "Default: `#{Config::DEFAULT_DIRS[:qlplugindir]}`", + }], + [:flag, "--mdimporterdir=", { + description: "Target location for Spotlight Plugins. " \ + "Default: `#{Config::DEFAULT_DIRS[:mdimporterdir]}`", + }], + [:flag, "--dictionarydir=", { + description: "Target location for Dictionaries. " \ + "Default: `#{Config::DEFAULT_DIRS[:dictionarydir]}`", + }], + [:flag, "--fontdir=", { + description: "Target location for Fonts. " \ + "Default: `#{Config::DEFAULT_DIRS[:fontdir]}`", + }], + [:flag, "--servicedir=", { + description: "Target location for Services. " \ + "Default: `#{Config::DEFAULT_DIRS[:servicedir]}`", + }], + [:flag, "--input_methoddir=", { + description: "Target location for Input Methods. " \ + "Default: `#{Config::DEFAULT_DIRS[:input_methoddir]}`", + }], + [:flag, "--internet_plugindir=", { + description: "Target location for Internet Plugins. " \ + "Default: `#{Config::DEFAULT_DIRS[:internet_plugindir]}`", + }], + [:flag, "--audio_unit_plugindir=", { + description: "Target location for Audio Unit Plugins. " \ + "Default: `#{Config::DEFAULT_DIRS[:audio_unit_plugindir]}`", + }], + [:flag, "--vst_plugindir=", { + description: "Target location for VST Plugins. " \ + "Default: `#{Config::DEFAULT_DIRS[:vst_plugindir]}`", + }], + [:flag, "--vst3_plugindir=", { + description: "Target location for VST3 Plugins. " \ + "Default: `#{Config::DEFAULT_DIRS[:vst3_plugindir]}`", + }], + [:flag, "--screen_saverdir=", { + description: "Target location for Screen Savers. " \ + "Default: `#{Config::DEFAULT_DIRS[:screen_saverdir]}`", + }], + [:comma_array, "--language", { + description: "Set language of the Cask to install. The first matching " \ + "language is used, otherwise the default language on the Cask. " \ + "The default value is the `language of your system`", + }], + ].freeze + def self.parser(&block) Homebrew::CLI::Parser.new do if block_given? @@ -91,52 +155,9 @@ module Cask EOS end - flag "--appdir=", - description: "Target location for Applications. " \ - "Default: `#{Config::DEFAULT_DIRS[:appdir]}`" - flag "--colorpickerdir=", - description: "Target location for Color Pickers. " \ - "Default: `#{Config::DEFAULT_DIRS[:colorpickerdir]}`" - flag "--prefpanedir=", - description: "Target location for Preference Panes. " \ - "Default: `#{Config::DEFAULT_DIRS[:prefpanedir]}`" - flag "--qlplugindir=", - description: "Target location for QuickLook Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:qlplugindir]}`" - flag "--mdimporterdir=", - description: "Target location for Spotlight Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:mdimporterdir]}`" - flag "--dictionarydir=", - description: "Target location for Dictionaries. " \ - "Default: `#{Config::DEFAULT_DIRS[:dictionarydir]}`" - flag "--fontdir=", - description: "Target location for Fonts. " \ - "Default: `#{Config::DEFAULT_DIRS[:fontdir]}`" - flag "--servicedir=", - description: "Target location for Services. " \ - "Default: `#{Config::DEFAULT_DIRS[:servicedir]}`" - flag "--input_methoddir=", - description: "Target location for Input Methods. " \ - "Default: `#{Config::DEFAULT_DIRS[:input_methoddir]}`" - flag "--internet_plugindir=", - description: "Target location for Internet Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:internet_plugindir]}`" - flag "--audio_unit_plugindir=", - description: "Target location for Audio Unit Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:audio_unit_plugindir]}`" - flag "--vst_plugindir=", - description: "Target location for VST Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:vst_plugindir]}`" - flag "--vst3_plugindir=", - description: "Target location for VST3 Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:vst3_plugindir]}`" - flag "--screen_saverdir=", - description: "Target location for Screen Savers. " \ - "Default: `#{Config::DEFAULT_DIRS[:screen_saverdir]}`" - comma_array "--language", - description: "Set language of the Cask to install. The first matching " \ - "language is used, otherwise the default language on the Cask. " \ - "The default value is the `language of your system`" + OPTIONS.each do |option| + send(*option) + end end end diff --git a/Library/Homebrew/cask/cmd/abstract_command.rb b/Library/Homebrew/cask/cmd/abstract_command.rb index 8247ee5323..5314cd931f 100644 --- a/Library/Homebrew/cask/cmd/abstract_command.rb +++ b/Library/Homebrew/cask/cmd/abstract_command.rb @@ -33,6 +33,22 @@ module Cask "`#{command_name}` []#{banner_args}" end + OPTIONS = [ + [:switch, "--[no-]binaries", { + description: "Disable/enable linking of helper executables to `#{Config.global.binarydir}`. " \ + "Default: enabled", + env: :cask_opts_binaries, + }], + [:switch, "--require-sha", { + description: "Require all casks to have a checksum.", + env: :cask_opts_require_sha, + }], + [:switch, "--[no-]quarantine", { + description: "Disable/enable quarantining of downloads. Default: enabled", + env: :cask_opts_quarantine, + }], + ].freeze + def self.parser(&block) banner = <<~EOS `cask` #{banner_headline} @@ -48,18 +64,9 @@ module Cask instance_eval(&block) if block_given? - switch "--[no-]binaries", - description: "Disable/enable linking of helper executables to `#{Config.global.binarydir}`. " \ - "Default: enabled", - env: :cask_opts_binaries - - switch "--require-sha", - description: "Require all casks to have a checksum.", - env: :cask_opts_require_sha - - switch "--[no-]quarantine", - description: "Disable/enable quarantining of downloads. Default: enabled", - env: :cask_opts_quarantine + OPTIONS.each do |option| + send(*option) + end min_named min_n unless min_n.nil? max_named max_n unless max_n.nil? diff --git a/Library/Homebrew/cask/cmd/install.rb b/Library/Homebrew/cask/cmd/install.rb index b2f1be6a96..a532bb521e 100644 --- a/Library/Homebrew/cask/cmd/install.rb +++ b/Library/Homebrew/cask/cmd/install.rb @@ -14,12 +14,20 @@ module Cask "Installs the given ." end + OPTIONS = [ + [:switch, "--skip-cask-deps", { + description: "Skip installing cask dependencies.", + }], + ].freeze + def self.parser(&block) super do switch "--force", description: "Force overwriting existing files." - switch "--skip-cask-deps", - description: "Skip installing cask dependencies." + + OPTIONS.each do |option| + send(*option) + end instance_eval(&block) if block_given? end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 9ae1ba145f..33f42ec12e 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require "cask/config" +require "cask/cmd" +require "cask/cmd/install" require "missing_formula" require "formula_installer" require "development_tools" @@ -16,50 +18,37 @@ module Homebrew module_function def install_args - cask_only_options = { - ["--cask", "--casks"] => { + cask_only_options = [ + [:switch, "--cask", "--casks", { description: "Treat all named arguments as casks.", - }, - ["--[no-]binaries"] => { - description: "Disable/enable linking of helper executables to `#{Cask::Config.global.binarydir}`. " \ - "Default: enabled", - env: :cask_opts_binaries, - }, - ["--require-sha"] => { - description: "Require all casks to have a checksum.", - env: :cask_opts_require_sha, - }, - ["--[no-]quarantine"] => { - description: "Disable/enable quarantining of downloads. Default: enabled", - env: :cask_opts_quarantine, - }, - ["--skip-cask-deps"] => { - description: "Skip installing cask dependencies.", - }, - }.freeze + }], + *Cask::Cmd::OPTIONS, + *Cask::Cmd::AbstractCommand::OPTIONS, + *Cask::Cmd::Install::OPTIONS, + ] - formula_only_options = { - ["--formula", "--formulae"] => { + formula_only_options = [ + [:switch, "--formula", "--formulae", { description: "Treat all named arguments as formulae.", - }, - ["--env="] => { + }], + [:flag, "--env=", { description: "If `std` is passed, use the standard build environment instead of superenv. "\ "If `super` is passed, use superenv even if the formula specifies the "\ "standard build environment.", - }, - ["--ignore-dependencies"] => { + }], + [:switch, "--ignore-dependencies", { description: "An unsupported Homebrew development flag to skip installing any dependencies of "\ "any kind. If the dependencies are not already present, the formula will have issues. "\ "If you're not developing Homebrew, consider adjusting your PATH rather than "\ "using this flag.", - }, - ["--only-dependencies"] => { + }], + [:switch, "--only-dependencies", { description: "Install the dependencies with specified options but do not install the "\ "formula itself.", - }, - ["--cc="] => { + }], + [:flag, "--cc=", { description: "Attempt to compile using the specified , which should be the "\ "name of the compiler's executable, e.g. `gcc-7` for GCC 7. "\ "In order to use LLVM's clang, specify `llvm_clang`. To use the "\ @@ -67,59 +56,56 @@ module Homebrew "compilers that are provided by Homebrew or bundled with macOS. "\ "Please do not file issues if you encounter errors while using this option.", - }, - ["-s", "--build-from-source"] => { + }], + [:switch, "-s", "--build-from-source", { description: "Compile from source even if a bottle is provided. "\ "Dependencies will still be installed from bottles if they are available.", - }, - ["--force-bottle"] => { + }], + [:switch, "--force-bottle", { description: "Install from a bottle if it exists for the current or newest version of "\ "macOS, even if it would not normally be used for installation.", - }, - ["--include-test"] => { + }], + [:switch, "--include-test", { description: "Install testing dependencies required to run `brew test` .", - }, - ["--HEAD"] => { + }], + [:switch, "--HEAD", { description: "If defines it, install the HEAD version, aka. master, trunk, unstable.", - }, - ["--fetch-HEAD"] => { + }], [:switch, "--fetch-HEAD", { description: "Fetch the upstream repository to detect if the HEAD installation of the "\ "formula is outdated. Otherwise, the repository's HEAD will only be checked for "\ "updates when a new stable or development version has been released.", - }, - ["--keep-tmp"] => { + }], [:switch, "--keep-tmp", { description: "Retain the temporary files created during installation.", - }, - ["--build-bottle"] => { + }], [:switch, "--build-bottle", { description: "Prepare the formula for eventual bottling during installation, skipping any "\ "post-install steps.", - }, - ["--bottle-arch="] => { + }], + [:flag, "--bottle-arch=", { depends_on: "--build-bottle", description: "Optimise bottles for the specified architecture rather than the oldest "\ "architecture supported by the version of macOS the bottles are built on.", - }, - ["--display-times"] => { + }], + [:switch, "--display-times", { env: :display_install_times, description: "Print install times for each formula at the end of the run.", - }, - ["-i", "--interactive"] => { + }], + [:switch, "-i", "--interactive", { description: "Download and patch , then open a shell. This allows the user to "\ "run `./configure --help` and otherwise determine how to turn the software "\ "package into a Homebrew package.", - }, - ["-g", "--git"] => { + }], + [:switch, "-g", "--git", { description: "Create a Git repository, useful for creating patches to the software.", - }, - }.freeze + }] + ] Homebrew::CLI::Parser.new do usage_banner <<~EOS @@ -134,27 +120,22 @@ module Homebrew description: "If brewing fails, open an interactive debugging session with access to IRB "\ "or a shell inside the temporary build directory." switch "-f", "--force", - description: "Install without checking for previously installed keg-only or "\ - "non-migrated versions." + description: "Install formulae without checking for previously installed keg-only or "\ + "non-migrated versions. Overwrite existing files when installing casks." switch "-v", "--verbose", description: "Print the verification and postinstall steps." conflicts "--ignore-dependencies", "--only-dependencies" conflicts "--build-from-source", "--build-bottle", "--force-bottle" - formula_only_options.each do |flags, **options| - if flags.last.end_with?("=") - flag(*flags, **options) - else - switch(*flags, **options) - end - - conflicts "--cask", flags.last + formula_only_options.each do |options| + send(*options) + conflicts "--cask", options[-2] end - cask_only_options.each do |flags, **options| - switch(*flags, **options) - conflicts "--formula", flags.last + cask_only_options.each do |options| + send(*options) + conflicts "--formula", options[-2] end formula_options @@ -187,8 +168,6 @@ module Homebrew formulae, casks = formulae_or_casks.partition { |formula_or_cask| formula_or_cask.is_a?(Formula) } if casks.any? - require "cask/cmd/install" - Cask::Cmd::Install.install_casks( *casks, binaries: args.binaries?, diff --git a/docs/Manpage.md b/docs/Manpage.md index c768b2ddfc..153c06c49e 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -314,7 +314,7 @@ installed formulae or, every 30 days, for all formulae. * `-d`, `--debug`: If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory. * `-f`, `--force`: - Install without checking for previously installed keg-only or non-migrated versions. + Install formulae without checking for previously installed keg-only or non-migrated versions. Overwrite existing files when installing casks. * `-v`, `--verbose`: Print the verification and postinstall steps. * `--formula`: @@ -351,6 +351,36 @@ installed formulae or, every 30 days, for all formulae. Create a Git repository, useful for creating patches to the software. * `--cask`: Treat all named arguments as casks. +* `--appdir`: + Target location for Applications. Default: `/Applications` +* `--colorpickerdir`: + Target location for Color Pickers. Default: `~/Library/ColorPickers` +* `--prefpanedir`: + Target location for Preference Panes. Default: `~/Library/PreferencePanes` +* `--qlplugindir`: + Target location for QuickLook Plugins. Default: `~/Library/QuickLook` +* `--mdimporterdir`: + Target location for Spotlight Plugins. Default: `~/Library/Spotlight` +* `--dictionarydir`: + Target location for Dictionaries. Default: `~/Library/Dictionaries` +* `--fontdir`: + Target location for Fonts. Default: `~/Library/Fonts` +* `--servicedir`: + Target location for Services. Default: `~/Library/Services` +* `--input_methoddir`: + Target location for Input Methods. Default: `~/Library/Input Methods` +* `--internet_plugindir`: + Target location for Internet Plugins. Default: `~/Library/Internet Plug-Ins` +* `--audio_unit_plugindir`: + Target location for Audio Unit Plugins. Default: `~/Library/Audio/Plug-Ins/Components` +* `--vst_plugindir`: + Target location for VST Plugins. Default: `~/Library/Audio/Plug-Ins/VST` +* `--vst3_plugindir`: + Target location for VST3 Plugins. Default: `~/Library/Audio/Plug-Ins/VST3` +* `--screen_saverdir`: + Target location for Screen Savers. Default: `~/Library/Screen Savers` +* `--language`: + Set language of the Cask to install. The first matching language is used, otherwise the default language on the Cask. The default value is the `language of your system` * `--[no-]binaries`: Disable/enable linking of helper executables to `/usr/local/bin`. Default: enabled * `--require-sha`: diff --git a/manpages/brew.1 b/manpages/brew.1 index 580fa1fbb2..d043615c77 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -457,7 +457,7 @@ If brewing fails, open an interactive debugging session with access to IRB or a . .TP \fB\-f\fR, \fB\-\-force\fR -Install without checking for previously installed keg\-only or non\-migrated versions\. +Install formulae without checking for previously installed keg\-only or non\-migrated versions\. Overwrite existing files when installing casks\. . .TP \fB\-v\fR, \fB\-\-verbose\fR @@ -532,6 +532,66 @@ Create a Git repository, useful for creating patches to the software\. Treat all named arguments as casks\. . .TP +\fB\-\-appdir\fR +Target location for Applications\. Default: \fB/Applications\fR +. +.TP +\fB\-\-colorpickerdir\fR +Target location for Color Pickers\. Default: \fB~/Library/ColorPickers\fR +. +.TP +\fB\-\-prefpanedir\fR +Target location for Preference Panes\. Default: \fB~/Library/PreferencePanes\fR +. +.TP +\fB\-\-qlplugindir\fR +Target location for QuickLook Plugins\. Default: \fB~/Library/QuickLook\fR +. +.TP +\fB\-\-mdimporterdir\fR +Target location for Spotlight Plugins\. Default: \fB~/Library/Spotlight\fR +. +.TP +\fB\-\-dictionarydir\fR +Target location for Dictionaries\. Default: \fB~/Library/Dictionaries\fR +. +.TP +\fB\-\-fontdir\fR +Target location for Fonts\. Default: \fB~/Library/Fonts\fR +. +.TP +\fB\-\-servicedir\fR +Target location for Services\. Default: \fB~/Library/Services\fR +. +.TP +\fB\-\-input_methoddir\fR +Target location for Input Methods\. Default: \fB~/Library/Input Methods\fR +. +.TP +\fB\-\-internet_plugindir\fR +Target location for Internet Plugins\. Default: \fB~/Library/Internet Plug\-Ins\fR +. +.TP +\fB\-\-audio_unit_plugindir\fR +Target location for Audio Unit Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/Components\fR +. +.TP +\fB\-\-vst_plugindir\fR +Target location for VST Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST\fR +. +.TP +\fB\-\-vst3_plugindir\fR +Target location for VST3 Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST3\fR +. +.TP +\fB\-\-screen_saverdir\fR +Target location for Screen Savers\. Default: \fB~/Library/Screen Savers\fR +. +.TP +\fB\-\-language\fR +Set language of the Cask to install\. The first matching language is used, otherwise the default language on the Cask\. The default value is the \fBlanguage of your system\fR +. +.TP \fB\-\-[no\-]binaries\fR Disable/enable linking of helper executables to \fB/usr/local/bin\fR\. Default: enabled .