language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/--prefix.rb
@@ -12,7 +12,7 @@ module Homebrew def __prefix_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `--prefix` [<formula>] + `--prefix` [<formula>] [<formula> ...] Display Homebrew's install path. *Default:*
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/--repository.rb
@@ -12,7 +12,7 @@ module Homebrew def __repository_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `--repository`, `--repo` [<user>`/`<repo>] + `--repository`, `--repo` [<user>`/`<repo>] [<user>`/`<repo> ...] Display where Homebrew's `.git` directory is located.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/cleanup.rb
@@ -14,7 +14,7 @@ def cleanup_args Homebrew::CLI::Parser.new do days = Homebrew::EnvConfig::ENVS[:HOMEBREW_CLEANUP_MAX_AGE_DAYS][:default] usage_banner <<~EOS - `cleanup` [<options>] [<formula>|<cask>] + `cleanup` [<options>] [<formula>|<cask>] [<formula>|<cask> ...] Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae. If arguments are specified,
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/deps.rb
@@ -18,7 +18,7 @@ module Homebrew def deps_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `deps` [<options>] [<formula>] + `deps` [<options>] [<formula>] [<formula> ...] Show dependencies for <formula>. Additional options specific to <formula> may be appended to the command. When given multiple formula arguments,
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/desc.rb
@@ -17,7 +17,7 @@ module Homebrew def desc_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `desc` [<options>] (<text>|`/`<text>`/`|<formula>) + `desc` [<options>] <text>|`/`<text>`/`|<formula> [<text>|`/`<text>`/`|<formula> ...] Display <formula>'s name and one-line description. Formula descriptions are cached; the cache is created on the @@ -35,7 +35,7 @@ def desc_args conflicts "--search", "--name", "--description" - named_args :formula + named_args :formula, min: 1 end end @@ -51,14 +51,10 @@ def desc end results = if search_type.nil? - raise FormulaUnspecifiedError if args.no_named? - desc = {} args.named.to_formulae.each { |f| desc[f.full_name] = f.desc } Descriptions.new(desc) else - raise UsageError, "this command requires a search term" if args.no_named? - query = args.named.join(" ") string_or_regex = query_regexp(query) CacheStoreDatabase.use(:descriptions) do |db|
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/fetch.rb
@@ -17,7 +17,7 @@ module Homebrew def fetch_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `fetch` [<options>] <formula> + `fetch` [<options>] <formula>|<cask> [<formula>|<cask> ...] Download a bottle (if available) or source packages for <formula>e and binaries for <cask>s. For files, also print SHA-256 checksums.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/home.rb
@@ -13,7 +13,7 @@ module Homebrew def home_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `home` [<formula>|<cask>] + `home` [<formula>|<cask>] [<formula>|<cask> ...] Open a <formula> or <cask>'s homepage in a browser, or open Homebrew's own homepage if no argument is provided.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/info.rb
@@ -25,7 +25,7 @@ module Homebrew def info_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `info` [<options>] [<formula>|<cask>] + `info` [<options>] [<formula>|<cask>] [<formula>|<cask> ...] Display brief statistics for your Homebrew installation.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/install.rb
@@ -24,7 +24,7 @@ module Homebrew def install_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `install` [<options>] <formula>|<cask> + `install` [<options>] <formula>|<cask> [<formula>|<cask> ...] Install a <formula> or <cask>. Additional options specific to a <formula> may be appended to the command.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/link.rb
@@ -15,7 +15,7 @@ module Homebrew def link_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `link`, `ln` [<options>] <formula> + `link`, `ln` [<options>] <formula> [<formula> ...] Symlink all of <formula>'s installed files into Homebrew's prefix. This is done automatically when you install formulae but can be useful for DIY
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/list.rb
@@ -15,7 +15,7 @@ module Homebrew def list_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `list`, `ls` [<options>] [<formula>|<cask>] + `list`, `ls` [<options>] [<formula>|<cask>] [<formula>|<cask> ...] List all installed formulae and casks.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/migrate.rb
@@ -13,7 +13,7 @@ module Homebrew def migrate_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `migrate` [<options>] <formula> + `migrate` [<options>] <formula> [<formula> ...] Migrate renamed packages to new names, where <formula> are old names of packages.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/missing.rb
@@ -15,7 +15,7 @@ module Homebrew def missing_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `missing` [<options>] [<formula>] + `missing` [<options>] [<formula>] [<formula> ...] Check the given <formula> kegs for missing dependencies. If no <formula> are provided, check all kegs. Will exit with a non-zero status if any kegs are found
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/options.rb
@@ -15,7 +15,7 @@ module Homebrew def options_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `options` [<options>] [<formula>] + `options` [<options>] [<formula>] [<formula> ...] Show install options specific to <formula>. EOS
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/outdated.rb
@@ -16,7 +16,7 @@ module Homebrew def outdated_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `outdated` [<options>] [<formula>|<cask>] + `outdated` [<options>] [<formula>|<cask>] [<formula>|<cask> ...] List installed casks and formulae that have an updated version available. By default, version information is displayed in interactive shells, and suppressed otherwise.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/pin.rb
@@ -13,7 +13,7 @@ module Homebrew def pin_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `pin` <formula> + `pin` <formula> [<formula> ...] Pin the specified <formula>, preventing them from being upgraded when issuing the `brew upgrade` <formula> command. See also `unpin`.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/postinstall.rb
@@ -14,7 +14,7 @@ module Homebrew def postinstall_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `postinstall` <formula> + `postinstall` <formula> [<formula> ...] Rerun the post-install steps for <formula>. EOS
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/readall.rb
@@ -13,7 +13,7 @@ module Homebrew def readall_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `readall` [<options>] [<tap>] + `readall` [<options>] [<tap>] [<tap> ...] Import all items from the specified <tap>, or from all installed taps if none is provided. This can be useful for debugging issues across all items when making
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/reinstall.rb
@@ -22,7 +22,7 @@ module Homebrew def reinstall_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `reinstall` [<options>] <formula>|<cask> + `reinstall` [<options>] <formula>|<cask> [<formula>|<cask> ...] Uninstall and then reinstall a <formula> or <cask> using the same options it was originally installed with, plus any appended options specific to a <formula>.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/search.rb
@@ -31,7 +31,7 @@ module Homebrew def search_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `search` [<options>] [<text>|`/`<text>`/`] + `search` [<options>] [<text>|`/`<text>`/`] [<text>|`/`<text>`/` ...] Perform a substring search of cask tokens and formula names for <text>. If <text> is flanked by slashes, it is interpreted as a regular expression.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/switch.rb
@@ -19,7 +19,7 @@ def switch_args Symlink all of the specified <version> of <formula>'s installation into Homebrew's prefix. EOS - named 2 + named_args number: 2 hide_from_man_page! end end
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/tap-info.rb
@@ -12,7 +12,7 @@ module Homebrew def tap_info_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `tap-info` [<options>] [<tap>] + `tap-info` [<options>] [<tap>] [<tap> ...] Show detailed information about one or more <tap>s.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/uninstall.rb
@@ -19,7 +19,7 @@ module Homebrew def uninstall_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `uninstall`, `rm`, `remove` [<options>] <formula>|<cask> + `uninstall`, `rm`, `remove` [<options>] <formula>|<cask> [<formula>|<cask> ...] Uninstall a <formula> or <cask>. EOS
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/unlink.rb
@@ -14,7 +14,7 @@ module Homebrew def unlink_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `unlink` [<options>] <formula> + `unlink` [<options>] <formula> [<formula> ...] Remove symlinks for <formula> from Homebrew's prefix. This can be useful for temporarily disabling a formula:
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/unpin.rb
@@ -13,7 +13,7 @@ module Homebrew def unpin_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `unpin` <formula> + `unpin` <formula> [<formula> ...] Unpin <formula>, allowing them to be upgraded by `brew upgrade` <formula>. See also `pin`.
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/untap.rb
@@ -12,7 +12,7 @@ module Homebrew def untap_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `untap` <tap> + `untap` <tap> [<tap> ...] Remove a tapped formula repository. EOS
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/update-reset.sh
@@ -1,4 +1,4 @@ -#: * `update-reset` [<repository>] +#: * `update-reset` [<repository>] [<repository> ...] #: #: Fetch and reset Homebrew and all tap repositories (or any specified <repository>) using `git`(1) to their latest `origin/master`. #:
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/upgrade.rb
@@ -18,7 +18,7 @@ module Homebrew def upgrade_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `upgrade` [<options>] [<formula>|<cask>] + `upgrade` [<options>] [<formula>|<cask>] [<formula>|<cask> ...] Upgrade outdated casks and outdated, unpinned formulae using the same options they were originally installed with, plus any appended brew formula options. If <cask> or <formula> are specified,
true
Other
Homebrew
brew
332372469fd38cec8bedebaf49c1cd7fce0de4a3.json
cmd: indicate multiple named args in usage banner
Library/Homebrew/cmd/uses.rb
@@ -21,7 +21,7 @@ module Homebrew def uses_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `uses` [<options>] <formula> + `uses` [<options>] <formula> [<formula> ...] Show formulae and casks that specify <formula> as a dependency (i.e. show dependents of <formula>). When given multiple formula arguments, show the intersection
true
Other
Homebrew
brew
eebc161ea51aa74a93ce3394aeab72a35a57ed04.json
Incorporate suggestions from code review Co-Authored-By: Seeker <meaningseeking@protonmail.com>
Library/Homebrew/cli/parser.rb
@@ -539,7 +539,7 @@ def check_named_args(args) def process_option(*args) option, = @parser.make_switch(args) - @processed_options.reject! { |existing| option.long.first.present? && existing.second == option.long.first } + @processed_options.reject! { |existing| existing.second == option.long.first } if option.long.first.present? @processed_options << [option.short.first, option.long.first, option.arg, option.desc.first] end
true
Other
Homebrew
brew
eebc161ea51aa74a93ce3394aeab72a35a57ed04.json
Incorporate suggestions from code review Co-Authored-By: Seeker <meaningseeking@protonmail.com>
Library/Homebrew/cmd/options.rb
@@ -39,8 +39,10 @@ def options puts_options Formula.to_a.sort, args: args elsif args.installed? puts_options Formula.installed.sort, args: args - elsif !args.command.nil? + elsif args.command.present? cmd_options = Commands.command_options(args.command) + odie "Unknown command: #{args.command}" if cmd_options.nil? + if args.compact? puts cmd_options.sort.map(&:first) * " " else
true
Other
Homebrew
brew
eebc161ea51aa74a93ce3394aeab72a35a57ed04.json
Incorporate suggestions from code review Co-Authored-By: Seeker <meaningseeking@protonmail.com>
Library/Homebrew/commands.rb
@@ -197,7 +197,7 @@ def rebuild_commands_completion_list HOMEBREW_CACHE.mkpath cmds = commands(aliases: true).reject do |cmd| - # TODO: remove the cask check when `brew cask` is removed + # TODO: (2.8) remove the cask check when `brew cask` is removed cmd.start_with?("cask ") || Homebrew::Completions::COMPLETIONS_EXCLUSION_LIST.include?(cmd) end @@ -206,8 +206,8 @@ def rebuild_commands_completion_list end def command_options(command) - path = Commands.path(command) - return unless path + path = self.path(command) + return if path.blank? if cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path) cmd_parser.processed_options.map do |short, long, _, desc| @@ -229,8 +229,8 @@ def command_options(command) end def named_args_type(command) - path = Commands.path(command) - return unless path + path = self.path(command) + return if path.blank? cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path) return if cmd_parser.blank?
true
Other
Homebrew
brew
3af16832d9baa6ebe3d85701734720d0fe75bea4.json
Generate bash completions automatically
Library/Homebrew/cli/parser.rb
@@ -16,7 +16,7 @@ module CLI class Parser extend T::Sig - attr_reader :processed_options, :hide_from_man_page + attr_reader :processed_options, :hide_from_man_page, :named_args_type def self.from_cmd_path(cmd_path) cmd_args_method_name = Commands.args_method_name(cmd_path) @@ -539,6 +539,7 @@ def check_named_args(args) def process_option(*args) option, = @parser.make_switch(args) + @processed_options.reject! { |existing| option.long.first.present? && existing.second == option.long.first } @processed_options << [option.short.first, option.long.first, option.arg, option.desc.first] end
true
Other
Homebrew
brew
3af16832d9baa6ebe3d85701734720d0fe75bea4.json
Generate bash completions automatically
Library/Homebrew/cmd/options.rb
@@ -3,8 +3,6 @@ require "formula" require "options" -require "cli/parser" -require "commands" module Homebrew extend T::Sig @@ -42,15 +40,7 @@ def options elsif args.installed? puts_options Formula.installed.sort, args: args elsif !args.command.nil? - path = Commands.path(args.command) - odie "Unknown command: #{args.command}" unless path - cmd_options = if cmd_parser = CLI::Parser.from_cmd_path(path) - cmd_parser.processed_options.map do |short, long, _, desc| - [long || short, desc] - end - else - cmd_comment_options(path) - end + cmd_options = Commands.command_options(args.command) if args.compact? puts cmd_options.sort.map(&:first) * " " else @@ -64,20 +54,6 @@ def options end end - def cmd_comment_options(cmd_path) - options = [] - comment_lines = cmd_path.read.lines.grep(/^#:/) - return options if comment_lines.empty? - - # skip the comment's initial usage summary lines - comment_lines.slice(2..-1).each do |line| - if / (?<option>-[-\w]+) +(?<desc>.*)$/ =~ line - options << [option, desc] - end - end - options - end - def puts_options(formulae, args:) formulae.each do |f| next if f.options.empty?
true
Other
Homebrew
brew
3af16832d9baa6ebe3d85701734720d0fe75bea4.json
Generate bash completions automatically
Library/Homebrew/cmd/upgrade.rb
@@ -90,7 +90,7 @@ def upgrade_args conflicts "--build-from-source", "--force-bottle" - named_args [:installed_formula, :installed_cask] + named_args [:outdated_formula, :outdated_cask] end end
true
Other
Homebrew
brew
3af16832d9baa6ebe3d85701734720d0fe75bea4.json
Generate bash completions automatically
Library/Homebrew/commands.rb
@@ -2,6 +2,7 @@ # frozen_string_literal: true require "cask/cmd" +require "completions" # Helper functions for commands. # @@ -91,10 +92,10 @@ def path(cmd) path end - def commands(aliases: false) + def commands(external: true, aliases: false) cmds = internal_commands cmds += internal_developer_commands - cmds += external_commands + cmds += external_commands if external cmds += internal_commands_aliases if aliases cmds += cask_commands(aliases: aliases).map { |cmd| "cask #{cmd}" } cmds.sort @@ -185,6 +186,7 @@ def find_commands(path) def rebuild_internal_commands_completion_list cmds = internal_commands + internal_developer_commands + internal_commands_aliases + cmds.reject! { |cmd| Homebrew::Completions::COMPLETIONS_EXCLUSION_LIST.include? cmd } file = HOMEBREW_REPOSITORY/"completions/internal_commands_list.txt" file.atomic_write("#{cmds.sort.join("\n")}\n") @@ -194,7 +196,45 @@ def rebuild_commands_completion_list # Ensure that the cache exists so we can build the commands list HOMEBREW_CACHE.mkpath + cmds = commands(aliases: true).reject do |cmd| + # TODO: remove the cask check when `brew cask` is removed + cmd.start_with?("cask ") || Homebrew::Completions::COMPLETIONS_EXCLUSION_LIST.include?(cmd) + end + file = HOMEBREW_CACHE/"all_commands_list.txt" - file.atomic_write("#{commands(aliases: true).sort.join("\n")}\n") + file.atomic_write("#{cmds.sort.join("\n")}\n") + end + + def command_options(command) + path = Commands.path(command) + return unless path + + if cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path) + cmd_parser.processed_options.map do |short, long, _, desc| + [long || short, desc] + end + else + options = [] + comment_lines = path.read.lines.grep(/^#:/) + return options if comment_lines.empty? + + # skip the comment's initial usage summary lines + comment_lines.slice(2..-1).each do |line| + if / (?<option>-[-\w]+) +(?<desc>.*)$/ =~ line + options << [option, desc] + end + end + options + end + end + + def named_args_type(command) + path = Commands.path(command) + return unless path + + cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path) + return if cmd_parser.blank? + + Array(cmd_parser.named_args_type) end end
true
Other
Homebrew
brew
3af16832d9baa6ebe3d85701734720d0fe75bea4.json
Generate bash completions automatically
Library/Homebrew/completions.rb
@@ -3,6 +3,7 @@ require "utils/link" require "settings" +require "erb" module Homebrew # Helper functions for generating shell completions. @@ -13,7 +14,28 @@ module Completions module_function + COMPLETIONS_DIR = (HOMEBREW_REPOSITORY/"completions").freeze + TEMPLATE_DIR = (HOMEBREW_LIBRARY_PATH/"completions").freeze + SHELLS = %w[bash fish zsh].freeze + COMPLETIONS_EXCLUSION_LIST = %w[ + instal + uninstal + update-report + ].freeze + + BASH_NAMED_ARGS_COMPLETION_FUNCTION_MAPPING = { + formula: "__brew_complete_formulae", + installed_formula: "__brew_complete_installed_formulae", + outdated_formula: "__brew_complete_outdated_formulae", + cask: "__brew_complete_casks", + installed_cask: "__brew_complete_installed_casks", + outdated_cask: "__brew_complete_outdated_casks", + tap: "__brew_complete_tapped", + installed_tap: "__brew_complete_tapped", + command: "__brew_complete_commands", + diagnostic_check: '__brewcomp "$(brew doctor --list-checks)"', + }.freeze sig { void } def link! @@ -65,5 +87,85 @@ def show_completions_message_if_needed Settings.write :completionsmessageshown, true end + + sig { void } + def update_shell_completions! + commands = Commands.commands(external: false, aliases: true).sort + + (COMPLETIONS_DIR/"bash/brew").atomic_write generate_bash_completion_file(commands) + end + + sig { params(command: String).returns(T::Boolean) } + def command_gets_completions?(command) + return false if command.start_with? "cask " # TODO: remove when `brew cask` commands are removed + + command_options(command).any? + end + + sig { params(command: String).returns(T::Array[String]) } + def command_options(command) + options = [] + Commands.command_options(command)&.each do |option| + next if option.blank? + + name = option.first + if name.start_with? "--[no-]" + options << name.remove("[no-]") + options << name.sub("[no-]", "no-") + else + options << name + end + end&.compact + options.sort + end + + sig { params(command: String).returns(T.nilable(String)) } + def generate_bash_subcommand_completion(command) + return unless command_gets_completions? command + + named_completion_string = "" + if types = Commands.named_args_type(command) + named_args_strings, named_args_types = types.partition { |type| type.is_a? String } + + named_args_types.each do |type| + next unless BASH_NAMED_ARGS_COMPLETION_FUNCTION_MAPPING.key? type + + named_completion_string += "\n #{BASH_NAMED_ARGS_COMPLETION_FUNCTION_MAPPING[type]}" + end + + named_completion_string += "\n __brewcomp \"#{named_args_strings.join(" ")}\"" if named_args_strings.any? + end + + <<~COMPLETION + _brew_#{Commands.method_name command}() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + #{command_options(command).join("\n ")} + " + return + ;; + esac#{named_completion_string} + } + COMPLETION + end + + sig { params(commands: T::Array[String]).returns(T.nilable(String)) } + def generate_bash_completion_file(commands) + variables = OpenStruct.new + + variables[:completion_functions] = commands.map do |command| + generate_bash_subcommand_completion command + end.compact + + variables[:function_mappings] = commands.map do |command| + next unless command_gets_completions? command + + "#{command}) _brew_#{Commands.method_name command} ;;" + end.compact + + ERB.new((TEMPLATE_DIR/"bash.erb").read, trim_mode: ">").result(variables.instance_eval { binding }) + end end end
true
Other
Homebrew
brew
3af16832d9baa6ebe3d85701734720d0fe75bea4.json
Generate bash completions automatically
Library/Homebrew/completions/bash.erb
@@ -0,0 +1,167 @@ +<% +# To make changes to the completions: +# +# - For changes to a command under `COMMANDS` or `DEVELOPER COMMANDS` sections): +# - Find the source file in `Library/Homebrew/[dev-]cmd/<command>.{rb,sh}`. +# - For `.rb` files, edit the `<command>_args` method. +# - For `.sh` files, edit the top comment, being sure to use the line prefix +# `#:` for the comments to be recognized as documentation. If in doubt, +# compare with already documented commands. +# - For other changes: Edit this file. +# +# When done, regenerate the completions by running `brew man`. +%> +# Bash completion script for brew(1) + +# Indicates there are no completions +__brewcomp_null() { + COMPREPLY="" +} + +__brewcomp_words_include() { + local i=1 + while [[ "$i" -lt "$COMP_CWORD" ]] + do + if [[ "${COMP_WORDS[i]}" = "$1" ]] + then + return 0 + fi + (( i++ )) + done + return 1 +} + +# Find the previous non-switch word +__brewcomp_prev() { + local idx="$((COMP_CWORD - 1))" + local prv="${COMP_WORDS[idx]}" + while [[ "$prv" = -* ]] + do + (( idx-- )) + prv="${COMP_WORDS[idx]}" + done + echo "$prv" +} + +__brewcomp() { + # break $1 on space, tab, and newline characters, + # and turn it into a newline separated list of words + local list s sep=$'\n' IFS=$' \t\n' + local cur="${COMP_WORDS[COMP_CWORD]}" + + for s in $1 + do + __brewcomp_words_include "$s" && continue + list="$list$s$sep" + done + + IFS="$sep" + COMPREPLY=($(compgen -W "$list" -- "$cur")) +} + +# Don't use __brewcomp() in any of the __brew_complete_foo functions, as +# it is too slow and is not worth it just for duplicate elimination. +__brew_complete_formulae() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local formulae="$(brew formulae)" + COMPREPLY=($(compgen -W "$formulae" -- "$cur")) +} + +__brew_complete_casks() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local casks="$(brew casks)" + COMPREPLY=($(compgen -W "$casks" -- "$cur")) +} + +__brew_complete_installed_formulae() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local installed_formulae="$(command ls "$(brew --cellar)" 2>/dev/null)" + COMPREPLY=($(compgen -W "$installed_formulae" -- "$cur")) +} + +__brew_complete_installed_casks() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local installed_casks="$(command ls "$(brew --caskroom)" 2>/dev/null)" + COMPREPLY=($(compgen -W "$installed_casks" -- "$cur")) +} + +__brew_complete_outdated_formulae() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local outdated_formulae="$(brew outdated --formula --quiet)" + COMPREPLY=($(compgen -W "$outdated_formulae" -- "$cur")) +} + +__brew_complete_outdated_casks() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local outdated_casks="$(brew outdated --cask --quiet)" + COMPREPLY=($(compgen -W "$outdated_casks" -- "$cur")) +} + +__brew_complete_tapped() { + local taplib="$(brew --repository)/Library/Taps" + local dir taps + + for dir in "$taplib"/*/* + do + [[ -d "$dir" ]] || continue + dir="${dir#${taplib}/}" + dir="${dir/homebrew-/}" + taps="$taps $dir" + done + __brewcomp "$taps" +} + +__brew_complete_commands() { + local cur="${COMP_WORDS[COMP_CWORD]}" + HOMEBREW_CACHE=$(brew --cache) + HOMEBREW_REPOSITORY=$(brew --repo) + # Do not auto-complete "*instal" or "*uninstal" aliases for "*install" commands. + [[ -f "$HOMEBREW_CACHE/all_commands_list.txt" ]] && + local cmds="$(cat "$HOMEBREW_CACHE/all_commands_list.txt" | \grep -v instal$)" || + local cmds="$(cat "$HOMEBREW_REPOSITORY/completions/internal_commands_list.txt" | \grep -v instal$)" + COMPREPLY=($(compgen -W "$cmds" -- "$cur")) +} + +<%= completion_functions.join("\n") %> + +_brew() { + local i=1 cmd + + # find the subcommand + while [[ "$i" -lt "$COMP_CWORD" ]] + do + local s="${COMP_WORDS[i]}" + case "$s" in + --*) + cmd="$s" + break + ;; + -*) + ;; + *) + cmd="$s" + break + ;; + esac + (( i++ )) + done + + if [[ "$i" -eq "$COMP_CWORD" ]] + then + __brew_complete_commands + return + fi + + # subcommands have their own completion functions + case "$cmd" in + <%= function_mappings.join("\n ").concat("\n") %> + *) ;; + esac +} + +# keep around for compatibility +_brew_to_completion() { + _brew +} + +complete -o bashdefault -o default -F _brew brew
true
Other
Homebrew
brew
3af16832d9baa6ebe3d85701734720d0fe75bea4.json
Generate bash completions automatically
Library/Homebrew/dev-cmd/man.rb
@@ -5,6 +5,7 @@ require "erb" require "ostruct" require "cli/parser" +require "completions" module Homebrew extend T::Sig @@ -42,6 +43,7 @@ def man Commands.rebuild_internal_commands_completion_list regenerate_man_pages(preserve_date: args.fail_if_changed?, quiet: args.quiet?) + Completions.update_shell_completions! diff = system_command "git", args: [ "-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", "docs/Manpage.md", "manpages", "completions"
true
Other
Homebrew
brew
3af16832d9baa6ebe3d85701734720d0fe75bea4.json
Generate bash completions automatically
completions/bash/brew
@@ -54,29 +54,34 @@ __brew_complete_formulae() { COMPREPLY=($(compgen -W "$formulae" -- "$cur")) } -__brew_complete_installed() { +__brew_complete_casks() { local cur="${COMP_WORDS[COMP_CWORD]}" - local inst="$(command ls "$(brew --cellar)" 2>/dev/null)" - COMPREPLY=($(compgen -W "$inst" -- "$cur")) + local casks="$(brew casks)" + COMPREPLY=($(compgen -W "$casks" -- "$cur")) } -__brew_complete_outdated() { +__brew_complete_installed_formulae() { local cur="${COMP_WORDS[COMP_CWORD]}" - local od="$(brew outdated --quiet)" - COMPREPLY=($(compgen -W "$od" -- "$cur")) + local installed_formulae="$(command ls "$(brew --cellar)" 2>/dev/null)" + COMPREPLY=($(compgen -W "$installed_formulae" -- "$cur")) } -__brew_complete_versions() { - local formula="$1" - local versions="$(brew list --versions "$formula")" +__brew_complete_installed_casks() { local cur="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=($(compgen -W "$versions" -X "$formula" -- "$cur")) + local installed_casks="$(command ls "$(brew --caskroom)" 2>/dev/null)" + COMPREPLY=($(compgen -W "$installed_casks" -- "$cur")) } -__brew_complete_logs() { +__brew_complete_outdated_formulae() { local cur="${COMP_WORDS[COMP_CWORD]}" - local logs="$(command ls "${HOMEBREW_LOGS:-${HOME}/Library/Logs/Homebrew/}" 2>/dev/null)" - COMPREPLY=($(compgen -W "$logs" -- "$cur")) + local outdated_formulae="$(brew outdated --formula --quiet)" + COMPREPLY=($(compgen -W "$outdated_formulae" -- "$cur")) +} + +__brew_complete_outdated_casks() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local outdated_casks="$(brew outdated --cask --quiet)" + COMPREPLY=($(compgen -W "$outdated_casks" -- "$cur")) } __brew_complete_tapped() { @@ -104,723 +109,2208 @@ __brew_complete_commands() { COMPREPLY=($(compgen -W "$cmds" -- "$cur")) } -_brew_analytics() { - case "$COMP_CWORD" in - 2) __brewcomp "off on regenerate-uuid state" ;; +_brew___cache() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --build-from-source + --cask + --debug + --force-bottle + --formula + --help + --quiet + --verbose + " + return + ;; esac + __brew_complete_formulae + __brew_complete_casks } -_brew_bottle() { +_brew___caskroom() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) __brewcomp " - --debug - --force-core-tap - --help - --json - --keep-old - --merge - --no-commit - --no-rebuild - --or-later - --root-url - --skip-relocation - --verbose - --write - " + --debug + --help + --quiet + --verbose + " return ;; esac - __brew_complete_installed + __brew_complete_casks } -_brew_cleanup() { +_brew___cellar() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) __brewcomp " - --debug - --dry-run - --prune - --help - --verbose - -s - " + --debug + --help + --quiet + --verbose + " return ;; esac - __brew_complete_installed + __brew_complete_formulae } -_brew_create() { +_brew___config() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) __brewcomp " - --HEAD - --autotools - --cmake - --crystal --debug - --force - --go --help - --meson - --no-fetch - --node - --perl - --python - --ruby - --rust - --set-name - --set-version - --tap + --quiet --verbose " return ;; esac } -_brew_deps() { +_brew___env() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--1 --all --tree" + __brewcomp " + --debug + --help + --plain + --quiet + --shell + --verbose + " return ;; esac __brew_complete_formulae } -_brew_desc() { +_brew___prefix() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--search --name --description" + __brewcomp " + --debug + --help + --quiet + --unbrewed + --verbose + " return ;; esac __brew_complete_formulae } -_brew_diy() { +_brew___repo() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--set-name --set-version" + __brewcomp " + --debug + --help + --quiet + --verbose + " return ;; esac + __brew_complete_tapped } -_brew_doctor() { - local cur="${COMP_WORDS[COMP_CWORD]}" - __brewcomp "$(brew doctor --list-checks)" -} - -_brew_fetch() { +_brew___repository() { local cur="${COMP_WORDS[COMP_CWORD]}" - local prv="$(__brewcomp_prev)" case "$cur" in -*) __brewcomp " - --deps --force - --HEAD - --build-from-source --force-bottle --build-bottle - --retry - $(brew options --compact "$prv" 2>/dev/null) - " + --debug + --help + --quiet + --verbose + " return ;; esac - __brew_complete_formulae + __brew_complete_tapped } -_brew_gist_logs() { +_brew___version() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--new-issue" + __brewcomp " + --debug + --help + --quiet + --verbose + " return ;; esac - __brew_complete_logs } -_brew_info() { +_brew__s() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--all --github --installed --json=v1" + __brewcomp " + --cask + --closed + --debian + --debug + --desc + --fedora + --fink + --formula + --help + --macports + --open + --opensuse + --pull-request + --quiet + --ubuntu + --verbose + " return ;; esac - __brew_complete_formulae } -_brew_install() { +_brew__v() { local cur="${COMP_WORDS[COMP_CWORD]}" - local prv="$(__brewcomp_prev)" - case "$cur" in -*) - if __brewcomp_words_include "--interactive" - then - __brewcomp "--git --HEAD" - else - __brewcomp " - --build-from-source --build-bottle --force-bottle - --debug - --HEAD - --ignore-dependencies - --interactive - --only-dependencies - --verbose - --display-times - $(brew options --compact "$prv" 2>/dev/null) - " - fi + __brewcomp " + --debug + --help + --quiet + --verbose + " return ;; esac - __brew_complete_formulae } -_brew_irb() { +_brew_abv() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--examples" + __brewcomp " + --all + --analytics + --cask + --category + --days + --debug + --formula + --github + --help + --installed + --json + --quiet + --verbose + " return ;; esac + __brew_complete_formulae + __brew_complete_casks } -_brew_link() { +_brew_analytics() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--dry-run --overwrite --force" + __brewcomp " + --debug + --help + --quiet + --verbose + " return ;; esac - __brew_complete_installed -} - -_brew_list() { - local allopts="--unbrewed --verbose --pinned --versions --multiple --cask" - local cur="${COMP_WORDS[COMP_CWORD]}" - - case "$cur" in - -*) - # most options to brew-list are mutually exclusive - if __brewcomp_words_include "--unbrewed" - then - return - elif __brewcomp_words_include "--verbose" - then - return - elif __brewcomp_words_include "--pinned" - then - return - # --multiple only applies with --versions - elif __brewcomp_words_include "--multiple" - then - __brewcomp "--versions" - return - elif __brewcomp_words_include "--versions" - then - __brewcomp "--multiple" - return - else - __brewcomp "$allopts" - return - fi - ;; - esac - - # --multiple excludes formulae and *implies* --versions... - if __brewcomp_words_include "--multiple" - then - __brewcomp "--versions" - else - __brew_complete_installed - fi + __brewcomp "state on off regenerate-uuid" } -_brew_livecheck() { +_brew_audit() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) __brewcomp " - --full-name - --tap - --all - --installed - --newer-only - --json - --quiet - --debug - --verbose - --help - " + --appcast + --audit-debug + --cask + --debug + --display-cop-names + --display-filename + --except + --except-cops + --fix + --formula + --git + --help + --new + --no-appcast + --online + --only + --only-cops + --quiet + --skip-style + --strict + --tap + --token-conflicts + --verbose + " return ;; esac __brew_complete_formulae + __brew_complete_casks } -_brew_log() { - # if git-completion is loaded, then we complete git-log options - declare -F _git_log >/dev/null || return +_brew_autoremove() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) __brewcomp " - $__git_log_common_options - $__git_log_shortlog_options - $__git_log_gitk_options - $__git_diff_common_options - --walk-reflogs --graph --decorate - --abbrev-commit --oneline --reverse - " + --debug + --dry-run + --help + --quiet + --verbose + " return ;; esac - __brew_complete_formulae } -_brew_man() { +_brew_bottle() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--link --server --verbose" + __brewcomp " + --debug + --force-core-tap + --help + --json + --keep-old + --merge + --no-commit + --no-rebuild + --quiet + --root-url + --skip-relocation + --verbose + --write + " return ;; esac + __brew_complete_installed_formulae } -_brew_options() { +_brew_bump() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--all --compact --installed" + __brewcomp " + --debug + --help + --limit + --quiet + --verbose + " return ;; esac __brew_complete_formulae } -_brew_outdated() { +_brew_bump_cask_pr() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--quiet --verbose --formula --cask --json=v1 --fetch-HEAD --greedy" + __brewcomp " + --commit + --debug + --dry-run + --force + --help + --message + --no-audit + --no-browse + --no-fork + --no-style + --online + --quiet + --sha256 + --url + --verbose + --version + --write + " return ;; esac - __brewcomp_null + __brew_complete_casks } -_brew_postinstall() { +_brew_bump_formula_pr() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--debug --verbose --force --help" + __brewcomp " + --commit + --debug + --dry-run + --force + --help + --message + --mirror + --no-audit + --no-browse + --no-fork + --online + --quiet + --revision + --sha256 + --strict + --tag + --url + --verbose + --version + --write + " return ;; esac - __brew_complete_installed + __brew_complete_formulae } -_brew_pull() { +_brew_bump_revision() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) __brewcomp " - --bintray-org - --bottle - --branch-okay - --bump - --clean - --ignore-whitespace - --no-pbcopy - --no-publish - --resolve - --test-bot-user - --warn-on-publish-failure + --debug + --dry-run + --help + --message + --quiet + --verbose " return ;; esac __brew_complete_formulae } -_brew_readall() { +_brew_bump_unversioned_casks() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--aliases --syntax" + __brewcomp " + --debug + --dry-run + --help + --limit + --quiet + --state-file + --verbose + " return ;; esac + __brew_complete_casks __brew_complete_tapped } -_brew_search() { +_brew_cask() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--cask --debian --desc --fedora --fink --macports --opensuse --ubuntu" + __brewcomp " + --appdir + --audio-unit-plugindir + --colorpickerdir + --debug + --dictionarydir + --fontdir + --help + --input-methoddir + --internet-plugindir + --language + --mdimporterdir + --prefpanedir + --qlplugindir + --quiet + --screen-saverdir + --servicedir + --verbose + --vst-plugindir + --vst3-plugindir + " return ;; esac - __brewcomp_null } -_brew_style() { +_brew_cat() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--fix --display-cop-names --only-cops --except-cops" + __brewcomp " + --cask + --debug + --formula + --help + --quiet + --verbose + " return ;; esac __brew_complete_formulae + __brew_complete_casks } -_brew_switch() { - case "$COMP_CWORD" in - 2) __brew_complete_installed ;; - 3) __brew_complete_versions "${COMP_WORDS[COMP_CWORD-1]}" ;; - *) ;; - esac -} - -_brew_tap() { +_brew_cleanup() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--full --force-auto-update --repair --list-pinned" + __brewcomp " + --debug + --dry-run + --help + --prune + --prune-prefix + --quiet + --verbose + -s + " return ;; esac - __brewcomp_null + __brew_complete_formulae + __brew_complete_casks } -_brew_tap_info() { +_brew_command() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--installed --json=v1" + __brewcomp " + --debug + --help + --quiet + --verbose + " return ;; esac - __brew_complete_tapped + __brew_complete_commands } -_brew_tap_new() { +_brew_commands() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--verbose" + __brewcomp " + --debug + --help + --include-aliases + --quiet + --verbose + " return ;; esac } -_brew_tap_unpin() { - __brewcomp "$(brew tap --list-pinned)" -} - -_brew_tests() { +_brew_completions() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--verbose" + __brewcomp " + --debug + --help + --quiet + --verbose + " return ;; esac + __brewcomp "state link unlink" } -_brew_uninstall() { +_brew_config() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--force" + __brewcomp " + --debug + --help + --quiet + --verbose + " return ;; esac - __brew_complete_installed } -_brew_unpack() { +_brew_configure() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--git --patch --destdir=" + __brewcomp " + --debug + --help + --name + --quiet + --verbose + --version + " return ;; esac - __brew_complete_formulae } -_brew_update() { +_brew_create() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--rebase --verbose" + __brewcomp " + --HEAD + --autotools + --cask + --cmake + --crystal + --debug + --force + --go + --help + --meson + --no-fetch + --node + --perl + --python + --quiet + --ruby + --rust + --set-license + --set-name + --set-version + --tap + --verbose + " return ;; esac } -_brew_upgrade() { +_brew_deps() { local cur="${COMP_WORDS[COMP_CWORD]}" - local prv="$(__brewcomp_prev)" - case "$cur" in -*) __brewcomp " - --all - --build-from-source --build-bottle --force-bottle - --cleanup - --cask - --debug - --verbose - --fetch-HEAD - --display-times - " + --1 + --all + --annotate + --cask + --debug + --for-each + --formula + --full-name + --help + --include-build + --include-optional + --include-requirements + --include-test + --installed + --quiet + --skip-recommended + --tree + --union + --verbose + -n + " return ;; esac - __brew_complete_outdated + __brew_complete_formulae + __brew_complete_casks } -_brew_uses() { +_brew_desc() { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in -*) - __brewcomp "--installed --recursive --include-build --include-test --include-optional --skip-recommended" - return - ;; + __brewcomp " + --debug + --description + --help + --name + --quiet + --search + --verbose + " + return + ;; + esac + __brew_complete_formulae +} + +_brew_dispatch_build_bottle() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --issue + --macos + --quiet + --tap + --upload + --verbose + --workflow + " + return + ;; + esac + __brew_complete_formulae +} + +_brew_diy() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --name + --quiet + --verbose + --version + " + return + ;; + esac +} + +_brew_doctor() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --audit-debug + --debug + --help + --list-checks + --quiet + --verbose + " + return + ;; + esac + __brewcomp "$(brew doctor --list-checks)" +} + +_brew_dr() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --audit-debug + --debug + --help + --list-checks + --quiet + --verbose + " + return + ;; + esac + __brewcomp "$(brew doctor --list-checks)" +} + +_brew_edit() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --formula + --help + --quiet + --verbose + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks +} + +_brew_environment() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --plain + --quiet + --shell + --verbose + " + return + ;; + esac + __brew_complete_formulae +} + +_brew_extract() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --force + --help + --quiet + --verbose + --version + " + return + ;; + esac + __brew_complete_formulae +} + +_brew_fetch() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --HEAD + --build-bottle + --build-from-source + --cask + --debug + --deps + --force + --force-bottle + --formula + --help + --no-quarantine + --quarantine + --quiet + --retry + --verbose + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks +} + +_brew_formula() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + esac + __brew_complete_formulae +} + +_brew_gist_logs() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --new-issue + --private + --quiet + --verbose + --with-hostname + " + return + ;; + esac + __brew_complete_formulae +} + +_brew_home() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --formula + --help + --quiet + --verbose + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks +} + +_brew_homepage() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --formula + --help + --quiet + --verbose + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks +} + +_brew_info() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --all + --analytics + --cask + --category + --days + --debug + --formula + --github + --help + --installed + --json + --quiet + --verbose + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks +} + +_brew_instal() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --HEAD + --appdir + --audio-unit-plugindir + --binaries + --bottle-arch + --build-bottle + --build-from-source + --cask + --cc + --colorpickerdir + --debug + --dictionarydir + --display-times + --env + --fetch-HEAD + --fontdir + --force + --force-bottle + --formula + --git + --help + --ignore-dependencies + --include-test + --input-methoddir + --interactive + --internet-plugindir + --keep-tmp + --language + --mdimporterdir + --no-binaries + --no-quarantine + --only-dependencies + --prefpanedir + --qlplugindir + --quarantine + --quiet + --require-sha + --screen-saverdir + --servicedir + --skip-cask-deps + --verbose + --vst-plugindir + --vst3-plugindir + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks +} + +_brew_install() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --HEAD + --appdir + --audio-unit-plugindir + --binaries + --bottle-arch + --build-bottle + --build-from-source + --cask + --cc + --colorpickerdir + --debug + --dictionarydir + --display-times + --env + --fetch-HEAD + --fontdir + --force + --force-bottle + --formula + --git + --help + --ignore-dependencies + --include-test + --input-methoddir + --interactive + --internet-plugindir + --keep-tmp + --language + --mdimporterdir + --no-binaries + --no-quarantine + --only-dependencies + --prefpanedir + --qlplugindir + --quarantine + --quiet + --require-sha + --screen-saverdir + --servicedir + --skip-cask-deps + --verbose + --vst-plugindir + --vst3-plugindir + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks +} + +_brew_install_bundler_gems() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + esac +} + +_brew_irb() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --examples + --help + --pry + --quiet + --verbose + " + return + ;; + esac +} + +_brew_leaves() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + esac +} + +_brew_link() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --dry-run + --force + --help + --overwrite + --quiet + --verbose + " + return + ;; + esac + __brew_complete_installed_formulae +} + +_brew_linkage() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cached + --debug + --help + --quiet + --reverse + --test + --verbose + " + return + ;; + esac + __brew_complete_installed_formulae +} + +_brew_list() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --formula + --full-name + --help + --multiple + --pinned + --quiet + --verbose + --versions + -1 + -l + -r + -t + " + return + ;; + esac + __brew_complete_installed_formulae + __brew_complete_installed_casks +} + +_brew_livecheck() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --all + --cask + --debug + --formula + --full-name + --help + --installed + --json + --newer-only + --quiet + --tap + --verbose + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks +} + +_brew_ln() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --dry-run + --force + --help + --overwrite + --quiet + --verbose + " + return + ;; + esac + __brew_complete_installed_formulae +} + +_brew_log() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --max-count + --oneline + --patch + --quiet + --stat + --verbose + -1 + " + return + ;; + esac + __brew_complete_formulae +} + +_brew_ls() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --formula + --full-name + --help + --multiple + --pinned + --quiet + --verbose + --versions + -1 + -l + -r + -t + " + return + ;; + esac + __brew_complete_installed_formulae + __brew_complete_installed_casks +} + +_brew_man() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --fail-if-changed + --help + --link + --quiet + --verbose + " + return + ;; + esac +} + +_brew_migrate() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --force + --help + --quiet + --verbose + " + return + ;; + esac + __brew_complete_installed_formulae +} + +_brew_mirror() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --bintray-org + --bintray-repo + --debug + --help + --no-publish + --quiet + --verbose + " + return + ;; + esac + __brew_complete_formulae +} + +_brew_missing() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --hide + --quiet + --verbose + " + return + ;; + esac + __brew_complete_formulae +} + +_brew_options() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --all + --command + --compact + --debug + --help + --installed + --quiet + --verbose + " + return + ;; + esac + __brew_complete_formulae +} + +_brew_outdated() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --fetch-HEAD + --formula + --greedy + --help + --json + --quiet + --verbose + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks +} + +_brew_pin() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + esac + __brew_complete_installed_formulae +} + +_brew_postinstall() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + esac + __brew_complete_installed_formulae +} + +_brew_pr_automerge() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --autosquash + --debug + --help + --ignore-failures + --publish + --quiet + --tap + --verbose + --with-label + --without-approval + --without-labels + " + return + ;; + esac +} + +_brew_pr_publish() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --autosquash + --debug + --help + --message + --quiet + --tap + --verbose + --workflow + " + return + ;; + esac +} + +_brew_pr_pull() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --artifact + --autosquash + --bintray-mirror + --bintray-org + --branch-okay + --clean + --debug + --dry-run + --help + --ignore-missing-artifacts + --keep-old + --message + --no-publish + --no-upload + --quiet + --resolve + --root-url + --tap + --verbose + --warn-on-upload-failure + --workflows + " + return + ;; + esac +} + +_brew_pr_upload() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --bintray-org + --debug + --dry-run + --help + --keep-old + --no-commit + --no-publish + --quiet + --root-url + --verbose + --warn-on-upload-failure + " + return + ;; + esac +} + +_brew_prof() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --stackprof + --verbose + " + return + ;; + esac + __brew_complete_commands +} + +_brew_readall() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --aliases + --debug + --help + --quiet + --syntax + --verbose + " + return + ;; + esac + __brew_complete_tapped +} + +_brew_reinstall() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --appdir + --audio-unit-plugindir + --binaries + --build-from-source + --cask + --colorpickerdir + --debug + --dictionarydir + --display-times + --fontdir + --force + --force-bottle + --formula + --help + --input-methoddir + --interactive + --internet-plugindir + --keep-tmp + --language + --mdimporterdir + --no-binaries + --no-quarantine + --prefpanedir + --qlplugindir + --quarantine + --quiet + --require-sha + --screen-saverdir + --servicedir + --skip-cask-deps + --verbose + --vst-plugindir + --vst3-plugindir + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks +} + +_brew_release_notes() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --markdown + --quiet + --verbose + " + return + ;; + esac +} + +_brew_remove() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --force + --formula + --help + --ignore-dependencies + --quiet + --verbose + --zap + " + return + ;; + esac + __brew_complete_installed_formulae + __brew_complete_installed_casks +} + +_brew_rm() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --force + --formula + --help + --ignore-dependencies + --quiet + --verbose + --zap + " + return + ;; + esac + __brew_complete_installed_formulae + __brew_complete_installed_casks +} + +_brew_ruby() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + -e + -r + " + return + ;; + esac +} + +_brew_search() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --closed + --debian + --debug + --desc + --fedora + --fink + --formula + --help + --macports + --open + --opensuse + --pull-request + --quiet + --ubuntu + --verbose + " + return + ;; + esac +} + +_brew_sh() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cmd + --debug + --env + --help + --quiet + --verbose + " + return + ;; + esac +} + +_brew_sponsors() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + esac +} + +_brew_style() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --display-cop-names + --except-cops + --fix + --formula + --help + --only-cops + --quiet + --reset-cache + --verbose + " + return + ;; + esac + __brew_complete_formulae + __brew_complete_casks + __brew_complete_tapped +} + +_brew_switch() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + esac +} + +_brew_tap() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --force-auto-update + --full + --help + --list-pinned + --quiet + --repair + --shallow + --verbose + " + return + ;; + esac + __brew_complete_tapped +} + +_brew_tap_info() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --installed + --json + --quiet + --verbose + " + return + ;; + esac + __brew_complete_tapped +} + +_brew_tap_new() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --branch + --debug + --help + --no-git + --pull-label + --quiet + --verbose + " + return + ;; + esac + __brew_complete_tapped +} + +_brew_tc() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --dir + --fail-if-not-changed + --file + --fix + --help + --ignore + --quiet + --suggest-typed + --update + --verbose + " + return + ;; + esac +} + +_brew_test() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --HEAD + --debug + --help + --keep-tmp + --quiet + --retry + --verbose + " + return + ;; + esac + __brew_complete_installed_formulae +} + +_brew_tests() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --byebug + --coverage + --debug + --generic + --help + --no-compat + --online + --only + --quiet + --seed + --verbose + " + return + ;; + esac +} + +_brew_typecheck() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --dir + --fail-if-not-changed + --file + --fix + --help + --ignore + --quiet + --suggest-typed + --update + --verbose + " + return + ;; + esac +} + +_brew_unbottled() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --dependents + --help + --quiet + --tag + --total + --verbose + " + return + ;; esac __brew_complete_formulae } -__brew_caskcomp_words_include () -{ - local i=1 - while [[ $i -lt $COMP_CWORD ]]; do - if [[ "${COMP_WORDS[i]}" = "$1" ]]; then - return 0 - fi - (( i++ )) - done - return 1 +_brew_uninstal() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --force + --formula + --help + --ignore-dependencies + --quiet + --verbose + --zap + " + return + ;; + esac + __brew_complete_installed_formulae + __brew_complete_installed_casks } -# Find the previous non-switch word -__brew_caskcomp_prev () -{ - local idx=$((COMP_CWORD - 1)) - local prv="${COMP_WORDS[idx]}" - while [[ $prv == -* ]]; do - (( idx-- )) - prv="${COMP_WORDS[idx]}" - done - echo "$prv" -} - -__brew_caskcomp () -{ - # break $1 on space, tab, and newline characters, - # and turn it into a newline separated list of words - local list s sep=$'\n' IFS=$' \t\n' - local cur="${COMP_WORDS[COMP_CWORD]}" - - for s in $1; do - __brew_caskcomp_words_include "$s" && continue - list="$list$s$sep" - done - - IFS="$sep" - COMPREPLY=($(compgen -W "$list" -- "$cur")) -} - -# Don't use __brew_caskcomp() in any of the __brew_cask_complete_foo functions, as -# it is too slow and is not worth it just for duplicate elimination. -__brew_cask_complete_formulae () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local casks=$(brew casks) +_brew_uninstall() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --cask + --debug + --force + --formula + --help + --ignore-dependencies + --quiet + --verbose + --zap + " + return + ;; + esac + __brew_complete_installed_formulae + __brew_complete_installed_casks +} - COMPREPLY=($(compgen -W "$casks" -- "$cur")) +_brew_unlink() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --dry-run + --help + --quiet + --verbose + " + return + ;; + esac + __brew_complete_installed_formulae } -__brew_cask_complete_installed () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local inst=$(brew list --cask -1) - COMPREPLY=($(compgen -W "$inst" -- "$cur")) +_brew_unpack() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --destdir + --force + --git + --help + --patch + --quiet + --verbose + " + return + ;; + esac + __brew_complete_formulae } -__brew_cask_complete_caskroom () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local caskroom_dir="$(brew --prefix)/Caskroom/" - local files=$(\ls ${caskroom_dir} 2>/dev/null) - COMPREPLY=($(compgen -W "$files" -- "$cur")) +_brew_unpin() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + esac + __brew_complete_installed_formulae } -__brew_cask_complete_outdated () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local greedy=$(__brew_caskcomp_words_include "--greedy" && echo "--greedy") - local outdated=$(brew outdated --cask --quiet $greedy) - COMPREPLY=($(compgen -W "$outdated" -- "$cur")) +_brew_untap() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + esac + __brew_complete_tapped } -_brew_cask_fetch () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prv=$(__brew_caskcomp_prev) - case "$cur" in +_brew_up() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in -*) - __brew_caskcomp "--force" - return - ;; - esac - __brew_cask_complete_formulae + __brewcomp " + --debug + --force + --help + --merge + --preinstall + --verbose + " + return + ;; + esac } -_brew_cask_install () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prv=$(__brew_caskcomp_prev) - case "$cur" in +_brew_update() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in -*) - __brew_caskcomp "--force --skip-cask-deps --require-sha --language" - return - ;; - esac - __brew_cask_complete_formulae + __brewcomp " + --debug + --force + --help + --merge + --preinstall + --verbose + " + return + ;; + esac } -_brew_cask_list () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - case "$cur" in +_brew_update_license_data() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in -*) - __brew_caskcomp "-1 --versions" - return - ;; - esac + __brewcomp " + --debug + --fail-if-not-changed + --help + --quiet + --verbose + " + return + ;; + esac +} - __brew_cask_complete_installed +_brew_update_python_resources() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --exclude-packages + --extra-packages + --help + --ignore-non-pypi-packages + --package-name + --print-only + --quiet + --silent + --verbose + --version + " + return + ;; + esac + __brew_complete_formulae } -_brew_cask_outdated () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - case "$cur" in +_brew_update_report() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in -*) - __brew_caskcomp "--greedy --verbose --quiet" - return - ;; - esac - __brew_cask_complete_installed + __brewcomp " + --debug + --force + --help + --preinstall + --quiet + --verbose + " + return + ;; + esac } -_brew_cask_style () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - case "$cur" in +_brew_update_test() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in -*) - __brew_caskcomp "--fix" - return - ;; - esac - __brew_cask_complete_installed + __brewcomp " + --before + --commit + --debug + --help + --keep-tmp + --quiet + --to-tag + --verbose + " + return + ;; + esac } -_brew_cask_uninstall () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - case "$cur" in +_brew_upgrade() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in -*) - __brew_caskcomp "--force" - return - ;; - esac - __brew_cask_complete_installed + __brewcomp " + --appdir + --audio-unit-plugindir + --binaries + --build-from-source + --cask + --colorpickerdir + --debug + --dictionarydir + --display-times + --dry-run + --fetch-HEAD + --fontdir + --force + --force-bottle + --formula + --greedy + --help + --ignore-pinned + --input-methoddir + --interactive + --internet-plugindir + --keep-tmp + --language + --mdimporterdir + --no-binaries + --no-quarantine + --prefpanedir + --qlplugindir + --quarantine + --quiet + --require-sha + --screen-saverdir + --servicedir + --skip-cask-deps + --verbose + --vst-plugindir + --vst3-plugindir + " + return + ;; + esac + __brew_complete_outdated_formulae + __brew_complete_outdated_casks } -_brew_cask_upgrade () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - case "$cur" in +_brew_uses() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in -*) - __brew_caskcomp "--force --greedy" - return - ;; - esac - __brew_cask_complete_outdated -} - -_brew_cask () -{ - local i=1 cmd - - # find the subcommand - while [[ $i -lt $COMP_CWORD ]]; do - local s="${COMP_WORDS[i]}" - case "$s" in - --*) - cmd="$s" - break - ;; - -*) - ;; - cask) - ;; - *) - cmd="$s" - break - ;; - esac - (( i++ )) - done - - if [[ $i -eq $COMP_CWORD ]]; then - __brew_caskcomp "abv audit cat create doctor edit fetch home info install list ls outdated reinstall remove rm search style uninstall upgrade zap -S --force --verbose --appdir --colorpickerdir --prefpanedir --qlplugindir --fontdir --servicedir --input-methoddir --internet-plugindir --screen-saverdir --no-binaries --debug --version" - return - fi + __brewcomp " + --cask + --debug + --formula + --help + --include-build + --include-optional + --include-test + --installed + --quiet + --recursive + --skip-recommended + --verbose + " + return + ;; + esac + __brew_complete_formulae +} - # subcommands have their own completion functions - case "$cmd" in - --version) __brewcomp_null ;; - audit) __brew_cask_complete_formulae ;; - cat) __brew_cask_complete_formulae ;; - create) ;; - doctor) __brewcomp_null ;; - edit) __brew_cask_complete_formulae ;; - fetch) _brew_cask_fetch ;; - home) __brew_cask_complete_formulae ;; - info|abv) __brew_cask_complete_formulae ;; - install|instal) _brew_cask_install ;; - list|ls) _brew_cask_list ;; - outdated) _brew_cask_outdated ;; - reinstall) __brew_cask_complete_installed ;; - search) __brewcomp_null ;; - style) _brew_cask_style ;; - uninstall|remove|rm) _brew_cask_uninstall ;; - upgrade) _brew_cask_upgrade ;; - zap) __brew_cask_complete_caskroom ;; - *) ;; - esac +_brew_vendor_gems() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + -*) + __brewcomp " + --debug + --help + --quiet + --update + --verbose + " + return + ;; + esac } _brew() { @@ -853,61 +2343,111 @@ _brew() { # subcommands have their own completion functions case "$cmd" in - --cache) __brew_complete_formulae ;; - --cellar) __brew_complete_formulae ;; - --prefix) __brew_complete_formulae ;; - analytics) _brew_analytics ;; - audit) __brew_complete_formulae ;; - bottle) _brew_bottle ;; - cask) _brew_cask ;; - cat) __brew_complete_formulae ;; - cleanup) _brew_cleanup ;; - command) __brew_complete_commands ;; - create) _brew_create ;; - deps) _brew_deps ;; - desc) _brew_desc ;; - diy|configure) _brew_diy ;; - doctor|dr) _brew_doctor ;; - edit) __brew_complete_formulae ;; - fetch) _brew_fetch ;; - gist-logs) _brew_gist_logs ;; - help) __brew_complete_commands ;; - home|homepage) __brew_complete_formulae ;; - info|abv) _brew_info ;; - install|instal) _brew_install ;; - irb) _brew_irb ;; - link|ln) _brew_link ;; - list|ls) _brew_list ;; - livecheck) _brew_livecheck ;; - log) _brew_log ;; - man) _brew_man ;; - missing) __brew_complete_formulae ;; - options) _brew_options ;; - outdated) _brew_outdated ;; - pin) __brew_complete_formulae ;; - postinstall) _brew_postinstall ;; - prof) __brew_complete_commands ;; - pull) _brew_pull ;; - readall) _brew_readall ;; - reinstall) _brew_install ;; - search|-S) _brew_search ;; - style) _brew_style ;; - switch) _brew_switch ;; - tap) _brew_tap ;; - tap-info) _brew_tap_info ;; - tap-new) _brew_tap_new ;; - tap-unpin) _brew_tap_unpin ;; - test) __brew_complete_installed ;; - tests) _brew_tests ;; - uninstall|remove|rm) _brew_uninstall ;; - unlink) __brew_complete_installed ;; - unpack) _brew_unpack ;; - unpin) __brew_complete_formulae ;; - untap) __brew_complete_tapped ;; - update|up) _brew_update ;; - upgrade) _brew_upgrade ;; - uses) _brew_uses ;; - *) ;; + --cache) _brew___cache ;; + --caskroom) _brew___caskroom ;; + --cellar) _brew___cellar ;; + --config) _brew___config ;; + --env) _brew___env ;; + --prefix) _brew___prefix ;; + --repo) _brew___repo ;; + --repository) _brew___repository ;; + --version) _brew___version ;; + -S) _brew__s ;; + -v) _brew__v ;; + abv) _brew_abv ;; + analytics) _brew_analytics ;; + audit) _brew_audit ;; + autoremove) _brew_autoremove ;; + bottle) _brew_bottle ;; + bump) _brew_bump ;; + bump-cask-pr) _brew_bump_cask_pr ;; + bump-formula-pr) _brew_bump_formula_pr ;; + bump-revision) _brew_bump_revision ;; + bump-unversioned-casks) _brew_bump_unversioned_casks ;; + cask) _brew_cask ;; + cat) _brew_cat ;; + cleanup) _brew_cleanup ;; + command) _brew_command ;; + commands) _brew_commands ;; + completions) _brew_completions ;; + config) _brew_config ;; + configure) _brew_configure ;; + create) _brew_create ;; + deps) _brew_deps ;; + desc) _brew_desc ;; + dispatch-build-bottle) _brew_dispatch_build_bottle ;; + diy) _brew_diy ;; + doctor) _brew_doctor ;; + dr) _brew_dr ;; + edit) _brew_edit ;; + environment) _brew_environment ;; + extract) _brew_extract ;; + fetch) _brew_fetch ;; + formula) _brew_formula ;; + gist-logs) _brew_gist_logs ;; + home) _brew_home ;; + homepage) _brew_homepage ;; + info) _brew_info ;; + instal) _brew_instal ;; + install) _brew_install ;; + install-bundler-gems) _brew_install_bundler_gems ;; + irb) _brew_irb ;; + leaves) _brew_leaves ;; + link) _brew_link ;; + linkage) _brew_linkage ;; + list) _brew_list ;; + livecheck) _brew_livecheck ;; + ln) _brew_ln ;; + log) _brew_log ;; + ls) _brew_ls ;; + man) _brew_man ;; + migrate) _brew_migrate ;; + mirror) _brew_mirror ;; + missing) _brew_missing ;; + options) _brew_options ;; + outdated) _brew_outdated ;; + pin) _brew_pin ;; + postinstall) _brew_postinstall ;; + pr-automerge) _brew_pr_automerge ;; + pr-publish) _brew_pr_publish ;; + pr-pull) _brew_pr_pull ;; + pr-upload) _brew_pr_upload ;; + prof) _brew_prof ;; + readall) _brew_readall ;; + reinstall) _brew_reinstall ;; + release-notes) _brew_release_notes ;; + remove) _brew_remove ;; + rm) _brew_rm ;; + ruby) _brew_ruby ;; + search) _brew_search ;; + sh) _brew_sh ;; + sponsors) _brew_sponsors ;; + style) _brew_style ;; + switch) _brew_switch ;; + tap) _brew_tap ;; + tap-info) _brew_tap_info ;; + tap-new) _brew_tap_new ;; + tc) _brew_tc ;; + test) _brew_test ;; + tests) _brew_tests ;; + typecheck) _brew_typecheck ;; + unbottled) _brew_unbottled ;; + uninstal) _brew_uninstal ;; + uninstall) _brew_uninstall ;; + unlink) _brew_unlink ;; + unpack) _brew_unpack ;; + unpin) _brew_unpin ;; + untap) _brew_untap ;; + up) _brew_up ;; + update) _brew_update ;; + update-license-data) _brew_update_license_data ;; + update-python-resources) _brew_update_python_resources ;; + update-report) _brew_update_report ;; + update-test) _brew_update_test ;; + upgrade) _brew_upgrade ;; + uses) _brew_uses ;; + vendor-gems) _brew_vendor_gems ;; + *) ;; esac }
true
Other
Homebrew
brew
3af16832d9baa6ebe3d85701734720d0fe75bea4.json
Generate bash completions automatically
completions/internal_commands_list.txt
@@ -46,7 +46,6 @@ help home homepage info -instal install install-bundler-gems irb @@ -92,7 +91,6 @@ test tests typecheck unbottled -uninstal uninstall unlink unpack @@ -102,7 +100,6 @@ up update update-license-data update-python-resources -update-report update-reset update-test upgrade
true
Other
Homebrew
brew
1d8372cbc86cb5391140e8b78b61de59496045f8.json
rubocops/*: improve test descriptions
Library/Homebrew/test/rubocops/components_order_spec.rb
@@ -6,7 +6,7 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do subject(:cop) { described_class.new } - context "When auditing formula components order" do + context "when auditing formula components order" do it "reports and corrects an offense when `uses_from_macos` precedes `depends_on`" do expect_offense(<<~RUBY) class Foo < Formula @@ -337,8 +337,8 @@ class Foo < Formula RUBY end - context "no on_os_block" do - it "does not fail when there is no on_os block" do + context "when formula has no OS-specific blocks" do + it "reports no offenses" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -352,8 +352,8 @@ def install end end - context "on_os_block" do - it "correctly uses on_macos and on_linux blocks" do + context "when formula has OS-specific block(s)" do + it "reports no offenses when `on_macos` and `on_linux` are used correctly" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -400,10 +400,8 @@ def install end RUBY end - end - context "on_macos_block" do - it "correctly uses as single on_macos block" do + it "reports no offenses when `on_macos` is used correctly" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -418,10 +416,8 @@ def install end RUBY end - end - context "on_linux_block" do - it "correctly uses as single on_linux block" do + it "reports no offenses when `on_linux` is used correctly" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh" @@ -516,7 +512,7 @@ class Foo < Formula RUBY end - it "reports no offenses for a valid `on_macos` and `on_linux` block with versions" do + it "reports no offenses for a valid `on_macos` and `on_linux` block (with `version`)" do expect_no_offenses(<<~RUBY) class Foo < Formula homepage "https://brew.sh"
true
Other
Homebrew
brew
1d8372cbc86cb5391140e8b78b61de59496045f8.json
rubocops/*: improve test descriptions
Library/Homebrew/test/rubocops/files_spec.rb
@@ -6,8 +6,8 @@ describe RuboCop::Cop::FormulaAudit::Files do subject(:cop) { described_class.new } - context "When auditing files" do - it "when the permissions are invalid" do + context "when auditing files" do + it "reports an offense when the permissions are invalid" do filename = Formulary.core_path("test_formula") File.open(filename, "w") do |file| FileUtils.chmod "-rwx", filename
true
Other
Homebrew
brew
1d8372cbc86cb5391140e8b78b61de59496045f8.json
rubocops/*: improve test descriptions
Library/Homebrew/test/rubocops/homepage_spec.rb
@@ -6,7 +6,7 @@ describe RuboCop::Cop::FormulaAudit::Homepage do subject(:cop) { described_class.new } - context "When auditing homepage" do + context "when auditing homepage" do it "reports an offense when there is no homepage" do expect_offense(<<~RUBY) class Foo < Formula
true
Other
Homebrew
brew
1d8372cbc86cb5391140e8b78b61de59496045f8.json
rubocops/*: improve test descriptions
Library/Homebrew/test/rubocops/lines_spec.rb
@@ -62,7 +62,7 @@ class Foo < Formula describe RuboCop::Cop::FormulaAudit::ClassInheritance do subject(:cop) { described_class.new } - context "auditing formula class inheritance" do + context "when auditing formula class inheritance" do it "reports an offense when not using spaces for class inheritance" do expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo<Formula @@ -78,7 +78,7 @@ class Foo<Formula describe RuboCop::Cop::FormulaAudit::Comments do subject(:cop) { described_class.new } - context "auditing comment text" do + context "when auditing comment text" do it "reports an offense when commented cmake calls exist" do expect_offense(<<~RUBY) class Foo < Formula @@ -132,7 +132,7 @@ class Foo < Formula describe RuboCop::Cop::FormulaAudit::AssertStatements do subject(:cop) { described_class.new } - context "auditing formula assertions" do + context "when auditing formula assertions" do it "reports an offense when assert ... include is used" do expect_offense(<<~RUBY) class Foo < Formula @@ -182,7 +182,7 @@ class Foo < Formula describe RuboCop::Cop::FormulaAudit::OptionDeclarations do subject(:cop) { described_class.new } - context "auditing options" do + context "when auditing options" do it "reports an offense when `build.without?` is used in homebrew/core" do expect_offense(<<~RUBY, "/homebrew-core/") class Foo < Formula @@ -417,7 +417,7 @@ def install; end describe RuboCop::Cop::FormulaAudit::ShellVariables do subject(:cop) { described_class.new } - context "When auditing shell variables" do + context "when auditing shell variables" do it "reports and corrects unexpanded shell variables in `Utils.popen`" do expect_offense(<<~RUBY) class Foo < Formula @@ -499,7 +499,7 @@ def install describe RuboCop::Cop::FormulaAudit::LicenseArrays do subject(:cop) { described_class.new } - context "When auditing license arrays" do + context "when auditing license arrays" do it "reports no offenses for license strings" do expect_no_offenses(<<~RUBY) class Foo < Formula @@ -554,7 +554,7 @@ class Foo < Formula describe RuboCop::Cop::FormulaAudit::Licenses do subject(:cop) { described_class.new } - context "When auditing licenses" do + context "when auditing licenses" do it "reports no offenses for license strings" do expect_no_offenses(<<~RUBY) class Foo < Formula @@ -638,7 +638,7 @@ class Foo < Formula describe RuboCop::Cop::FormulaAudit::PythonVersions do subject(:cop) { described_class.new } - context "When auditing Python versions" do + context "when auditing Python versions" do it "reports no offenses for Python with no dependency" do expect_no_offenses(<<~RUBY) class Foo < Formula @@ -685,7 +685,7 @@ def install RUBY end - it "reports no offenses when a Pytohn reference matches its dependency without `@`" do + it "reports no offenses when a Python reference matches its dependency without `@`" do expect_no_offenses(<<~RUBY) class Foo < Formula depends_on "python@3.9" @@ -818,7 +818,7 @@ def install describe RuboCop::Cop::FormulaAudit::Miscellaneous do subject(:cop) { described_class.new } - context "When auditing formula miscellany" do + context "when auditing formula miscellany" do it "reports an offense for unneeded `FileUtils` usage" do expect_offense(<<~RUBY) class Foo < Formula @@ -1339,7 +1339,7 @@ class Bar < Formula describe RuboCop::Cop::FormulaAuditStrict::ShellCommands do subject(:cop) { described_class.new } - context "When auditing shell commands" do + context "when auditing shell commands" do it "reports and corrects an offense when `system` arguments should be separated" do expect_offense(<<~RUBY) class Foo < Formula
true
Other
Homebrew
brew
1d8372cbc86cb5391140e8b78b61de59496045f8.json
rubocops/*: improve test descriptions
Library/Homebrew/test/rubocops/options_spec.rb
@@ -6,7 +6,7 @@ describe RuboCop::Cop::FormulaAudit::Options do subject(:cop) { described_class.new } - context "When auditing options" do + context "when auditing options" do it "reports an offense when using the 32-bit option" do expect_offense(<<~RUBY) class Foo < Formula
true
Other
Homebrew
brew
1d8372cbc86cb5391140e8b78b61de59496045f8.json
rubocops/*: improve test descriptions
Library/Homebrew/test/rubocops/patches_spec.rb
@@ -6,8 +6,8 @@ describe RuboCop::Cop::FormulaAudit::Patches do subject(:cop) { described_class.new } - context "When auditing legacy patches" do - it "reports no offenses when there is no legacy patch" do + context "when auditing legacy patches" do + it "reports no offenses if there is no legacy patch" do expect_no_offenses(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -155,7 +155,7 @@ def patches end end - context "When auditing inline patches" do + context "when auditing inline patches" do it "reports no offenses for valid inline patches" do expect_no_offenses(<<~RUBY) class Foo < Formula @@ -202,7 +202,7 @@ class Foo < Formula end end - context "When auditing external patches" do + context "when auditing external patches" do it "reports an offense for various patch URLs" do patch_urls = [ "https://raw.github.com/mogaal/sendemail",
true
Other
Homebrew
brew
1d8372cbc86cb5391140e8b78b61de59496045f8.json
rubocops/*: improve test descriptions
Library/Homebrew/test/rubocops/urls_spec.rb
@@ -183,8 +183,8 @@ }] } - context "When auditing urls" do - it "with offenses" do + context "when auditing URLs" do + it "reports any offenses" do formulae.each do |formula| allow_any_instance_of(RuboCop::Cop::FormulaCop).to receive(:formula_tap) .and_return(formula["formula_tap"]) @@ -211,7 +211,7 @@ class Foo < Formula end end - it "with offenses in stable/head block" do + it "reports an offense for GitHub repositories with git:// prefix" do expect_offense(<<~RUBY) class Foo < Formula desc "foo" @@ -228,7 +228,7 @@ class Foo < Formula RUBY end - it "with duplicate mirror" do + it "reports an offense if `url` is the same as `mirror`" do expect_offense(<<~RUBY) class Foo < Formula desc "foo"
true
Other
Homebrew
brew
1d8372cbc86cb5391140e8b78b61de59496045f8.json
rubocops/*: improve test descriptions
Library/Homebrew/test/rubocops/version_spec.rb
@@ -6,8 +6,8 @@ describe RuboCop::Cop::FormulaAudit::Version do subject(:cop) { described_class.new } - context "When auditing version" do - it "version should not be an empty string" do + context "when auditing version" do + it "reports an offense if `version` is an empty string" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -17,7 +17,7 @@ class Foo < Formula RUBY end - it "version should not have a leading 'v'" do + it "reports an offense if `version` has a leading 'v'" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' @@ -27,7 +27,7 @@ class Foo < Formula RUBY end - it "version should not end with underline and number" do + it "reports an offense if `version` ends with an underline and a number" do expect_offense(<<~RUBY) class Foo < Formula url 'https://brew.sh/foo-1.0.tgz'
true
Other
Homebrew
brew
3893cb312ed89223b866217b0418554d72964510.json
rubocops/text: improve test descriptions
Library/Homebrew/test/rubocops/text_spec.rb
@@ -6,8 +6,8 @@ describe RuboCop::Cop::FormulaAudit::Text do subject(:cop) { described_class.new } - context "When auditing formula text" do - it "with `require \"formula\"` is present" do + context "when auditing formula text" do + it 'reports an offense if `require "formula"` is present' do expect_offense(<<~RUBY) require "formula" ^^^^^^^^^^^^^^^^^ `require "formula"` is now unnecessary @@ -25,7 +25,7 @@ class Foo < Formula RUBY end - it "with both openssl and libressl optional dependencies" do + it "reports an offense if both openssl and libressl are dependencies" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -36,9 +36,7 @@ class Foo < Formula ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae should not depend on both OpenSSL and LibreSSL (even optionally). end RUBY - end - it "with both openssl and libressl dependencies" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -51,7 +49,7 @@ class Foo < Formula RUBY end - it "when veclibfort is used instead of OpenBLAS" do + it "reports an offense if veclibfort is used instead of OpenBLAS" do expect_offense(<<~RUBY, "/homebrew-core/") class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -62,7 +60,7 @@ class Foo < Formula RUBY end - it "when lapack is used instead of OpenBLAS" do + it "repots an offense if lapack is used instead of OpenBLAS" do expect_offense(<<~RUBY, "/homebrew-core/") class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -73,7 +71,7 @@ class Foo < Formula RUBY end - it "When xcodebuild is called without SYMROOT" do + it "reports an offense if xcodebuild is called without SYMROOT" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -87,7 +85,7 @@ def install RUBY end - it "When xcodebuild is called without any args" do + it "reports an offense if xcodebuild is called without any args" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -101,7 +99,7 @@ def install RUBY end - it "When go get is executed" do + it "reports an offense if `go get` is executed" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -115,7 +113,7 @@ def install RUBY end - it "When xcodebuild is executed" do + it "reports an offense if `xcodebuild` is executed" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -129,7 +127,7 @@ def install RUBY end - it "When plist_options are not defined when using a formula-defined plist", :ruby23 do + it "reports an offense if `plist_options` are not defined when using a formula-defined `plist`", :ruby23 do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -157,7 +155,7 @@ def plist RUBY end - it "When language/go is require'd" do + it 'reports an offense if `require "language/go"` is present' do expect_offense(<<~RUBY) require "language/go" ^^^^^^^^^^^^^^^^^^^^^ require "language/go" is unnecessary unless using `go_resource`s @@ -174,7 +172,7 @@ def install RUBY end - it "When formula uses virtualenv and also `setuptools` resource" do + it "reports an offense if formula uses virtualenv and also `setuptools` resource" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -193,7 +191,7 @@ def install RUBY end - it "When Formula.factory(name) is used" do + it "reports an offense if `Formula.factory(name)` is present" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -207,7 +205,7 @@ def install RUBY end - it "When dep ensure is used without `-vendor-only`" do + it "reports an offense if `dep ensure` is used without `-vendor-only`" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -221,7 +219,7 @@ def install RUBY end - it "When cargo build is executed" do + it "reports an offense if `cargo build` is executed" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -235,7 +233,7 @@ def install RUBY end - it "When make calls are not separated" do + it "reports an offense if `make` calls are not separated" do expect_offense(<<~RUBY) class Foo < Formula def install @@ -246,7 +244,7 @@ def install RUBY end - it "When concatenating in string interpolation" do + it "reports an offense if paths are concatenated in string interpolation" do expect_offense(<<~RUBY) class Foo < Formula def install @@ -257,7 +255,7 @@ def install RUBY end - it "When using `prefix + \"bin\"` instead of `bin`" do + it 'reports an offense if `prefix + "bin"` is present' do expect_offense(<<~RUBY) class Foo < Formula def install @@ -266,9 +264,7 @@ def install end end RUBY - end - it "When using `prefix + \"bin/foo\"` instead of `bin`" do expect_offense(<<~RUBY) class Foo < Formula def install @@ -284,8 +280,8 @@ def install describe RuboCop::Cop::FormulaAuditStrict::Text do subject(:cop) { described_class.new } - context "When auditing formula text" do - it "when deprecated `env :userpaths` is present" do + context "when auditing formula text" do + it "reports an offense if `env :userpaths` is present" do expect_offense(<<~RUBY) class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -296,7 +292,7 @@ class Foo < Formula RUBY end - it "when deprecated `env :std` is present in homebrew-core" do + it "reports an offense if `env :std` is present" do expect_offense(<<~RUBY, "/homebrew-core/") class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -307,7 +303,7 @@ class Foo < Formula RUBY end - it "when `\#{share}/foo` is used instead of `\#{pkgshare}`" do + it %Q(reports an offense if "\#{share}/<formula name>" is present) do expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula def install @@ -316,9 +312,7 @@ def install end end RUBY - end - it "when `\#{share}/foo/bar` is used instead of `\#{pkgshare}/bar`" do expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula def install @@ -327,11 +321,9 @@ def install end end RUBY - end - it "when `\#{share}/foolibc++` is used instead of `\#{pkgshare}/foolibc++`" do expect_offense(<<~RUBY, "/homebrew-core/Formula/foolibc++.rb") - class Foo < Formula + class Foolibcxx < Formula def install ohai "\#{share}/foolibc++" ^^^^^^^^^^^^^^^^^^^^ Use `\#{pkgshare}` instead of `\#{share}/foolibc++` @@ -340,7 +332,7 @@ def install RUBY end - it "when `share/\"foo\"` is used instead of `pkgshare`" do + it 'reports an offense if `share/"<formula name>"` is present' do expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula def install @@ -349,9 +341,7 @@ def install end end RUBY - end - it "when `share/\"foo/bar\"` is used instead of `pkgshare`" do expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula def install @@ -360,11 +350,9 @@ def install end end RUBY - end - it "when `share/\"foolibc++\"` is used instead of `pkgshare`" do expect_offense(<<~RUBY, "/homebrew-core/Formula/foolibc++.rb") - class Foo < Formula + class Foolibcxx < Formula def install ohai share/"foolibc++" ^^^^^^^^^^^^^^^^^ Use `pkgshare` instead of `share/"foolibc++"` @@ -373,7 +361,7 @@ def install RUBY end - it "when `\#{share}/foo-bar` doesn't match formula name" do + it %Q(reports no offenses if "\#{share}/<directory name>" doesn't match formula name) do expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula def install @@ -383,27 +371,23 @@ def install RUBY end - it "when `share/foo-bar` doesn't match formula name" do + it 'reports no offenses if `share/"<formula name>"` is not present' do expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula def install ohai share/"foo-bar" end end RUBY - end - it "when `share/bar` doesn't match formula name" do expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula def install ohai share/"bar" end end RUBY - end - it "when formula name appears afer `share/\"bar\"`" do expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula def install @@ -413,7 +397,7 @@ def install RUBY end - it "when formula name appears afer `\"\#{share}/bar\"`" do + it %Q(reports no offenses if formula name appears afer "\#{share}/<directory name>") do expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula def install
false
Other
Homebrew
brew
4710be2fb3a6f76c06a118f6d41e3c289c3f8324.json
parser: add some more tests
Library/Homebrew/test/cli/parser_spec.rb
@@ -397,6 +397,13 @@ expect { parser.parse([]) }.to raise_error(Homebrew::CLI::MinNamedArgumentsError) end + it "treats a symbol as a single argument of the specified type" do + formula_parser = described_class.new do + named :formula + end + expect { formula_parser.parse([]) }.to raise_error(UsageError, /this command requires a formula argument/) + end + it "doesn't allow more than the specified number of arguments" do expect { parser.parse(["foo", "bar"]) }.to raise_error(Homebrew::CLI::MaxNamedArgumentsError) end
false
Other
Homebrew
brew
74c101025616c98bc5774a9a84a7c34311c886d1.json
parser: add tests for named methods
Library/Homebrew/cli/parser.rb
@@ -519,7 +519,7 @@ def check_constraint_violations def check_named_args(args) exception = if @min_named_args && args.size < @min_named_args if @named_args_type.present? - types = @named_args_type.is_a?(Array) ? @named_args_type : [@named_args_type] + types = Array(@named_args_type) if types.any? { |arg| arg.is_a? String } MinNamedArgumentsError.new(@min_named_args) else
true
Other
Homebrew
brew
74c101025616c98bc5774a9a84a7c34311c886d1.json
parser: add tests for named methods
Library/Homebrew/test/cli/parser_spec.rb
@@ -317,4 +317,128 @@ expect(args.named).to be_empty end end + + describe "named_args" do + let(:parser_none) { + described_class.new do + named_args :none + end + } + let(:parser_number) { + described_class.new do + named_args number: 1 + end + } + + it "doesn't allow :none passed with a number" do + expect do + described_class.new do + named_args :none, number: 1 + end + end.to raise_error(ArgumentError, /Do not specify both `number`, `min` or `max` with `named_args :none`/) + end + + it "doesn't allow number and min" do + expect do + described_class.new do + named_args number: 1, min: 1 + end + end.to raise_error(ArgumentError, /Do not specify both `number` and `min` or `max`/) + end + + it "doesn't accept fewer than the passed number of arguments" do + expect { parser_number.parse([]) }.to raise_error(Homebrew::CLI::MinNamedArgumentsError) + end + + it "doesn't accept more than the passed number of arguments" do + expect { parser_number.parse(["foo", "bar"]) }.to raise_error(Homebrew::CLI::MaxNamedArgumentsError) + end + + it "accepts the passed number of arguments" do + expect { parser_number.parse(["foo"]) }.not_to raise_error + end + + it "doesn't accept any arguments with :none" do + expect { parser_none.parse(["foo"]) } + .to raise_error(Homebrew::CLI::MaxNamedArgumentsError, /This command does not take named arguments/) + end + + it "accepts no arguments with :none" do + expect { parser_none.parse([]) }.not_to raise_error + end + + it "displays the correct error message with an array of strings" do + parser = described_class.new do + named_args %w[on off], min: 1 + end + expect { parser.parse([]) }.to raise_error(Homebrew::CLI::MinNamedArgumentsError) + end + + it "displays the correct error message with an array of symbols" do + parser = described_class.new do + named_args [:formula, :cask], min: 1 + end + expect { parser.parse([]) }.to raise_error(UsageError, /this command requires a formula or cask argument/) + end + end + + describe "named" do + subject(:parser) { + described_class.new do + named 1 + end + } + + it "allows the specified number of arguments" do + expect { parser.parse(["foo"]) }.not_to raise_error + end + + it "doesn't allow less than the specified number of arguments" do + expect { parser.parse([]) }.to raise_error(Homebrew::CLI::MinNamedArgumentsError) + end + + it "doesn't allow more than the specified number of arguments" do + expect { parser.parse(["foo", "bar"]) }.to raise_error(Homebrew::CLI::MaxNamedArgumentsError) + end + end + + describe "min_named" do + subject(:parser) { + described_class.new do + min_named 1 + end + } + + it "doesn't allow less than the minimum number of arguments" do + expect { parser.parse([]) }.to raise_error(Homebrew::CLI::MinNamedArgumentsError) + end + + it "allows the minimum number of arguments" do + expect { parser.parse(["foo"]) }.not_to raise_error + end + + it "allows more than the specified number of arguments" do + expect { parser.parse(["foo", "bar"]) }.not_to raise_error + end + end + + describe "max_named" do + subject(:parser) { + described_class.new do + max_named 1 + end + } + + it "doesn't allow more than the minimum number of arguments" do + expect { parser.parse(["foo", "bar"]) }.to raise_error(Homebrew::CLI::MaxNamedArgumentsError) + end + + it "allows the minimum number of arguments" do + expect { parser.parse(["foo"]) }.not_to raise_error + end + + it "allows less than the specified number of arguments" do + expect { parser.parse([]) }.not_to raise_error + end + end end
true
Other
Homebrew
brew
fb29dec0de185c8154c602612e4638d3b878a33f.json
Improve livecheck docs.
docs/Brew-Livecheck.md
@@ -11,7 +11,7 @@ When livecheck isn't given instructions for how to check for upstream versions, 1. If a strategy can be applied, use it to check for new versions. 1. Return the newest version (or an error if versions could not be found at any available URLs). -It's sometimes necessary to override this default behavior to create a working check for a formula/cask. If a source doesn't provide the newest version, we need to check a different one. If livecheck doesn't correctly match version text, we need to provide an appropriate regex. +It's sometimes necessary to override this default behavior to create a working check. If a source doesn't provide the newest version, we need to check a different one. If livecheck doesn't correctly match version text, we need to provide an appropriate regex or `strategy` block. This can be accomplished by adding a `livecheck` block to the formula/cask. For more information on the available methods, please refer to the [`Livecheck` class documentation](https://rubydoc.brew.sh/Livecheck.html). @@ -25,9 +25,9 @@ This can be accomplished by adding a `livecheck` block to the formula/cask. For ### General guidelines -* **Only use `strategy` when it's necessary**. For example, if livecheck is already using `Git` for a URL, it's not necessary to use `strategy :git`. However, if `Git` applies to a URL but we need to use `PageMatch`, it's necessary to use `strategy :page_match`. +* **Only use `strategy` when it's necessary**. For example, if livecheck is already using `Git` for a URL, it's not necessary to use `strategy :git`. However, if `Git` applies to a URL but we need to use `PageMatch`, it's necessary to specify `strategy :page_match`. -* **Only use the `GithubLatest` strategy when it's necessary and correct**. Github.com rate limits requests and we try to minimize our use of this strategy to avoid hitting the rate limit on CI or when using `brew livecheck --tap` on large taps (e.g. homebrew/core). The `Git` strategy is often sufficient and we only need to use `GithubLatest` when the "latest" release is different than the newest version from the tags. +* **Only use the `GithubLatest` strategy when it's necessary and correct**. `github.com` rate limits requests and we try to minimize our use of this strategy to avoid hitting the rate limit on CI or when using `brew livecheck --tap` on large taps (e.g. homebrew/core). The `Git` strategy is often sufficient and we only need to use `GithubLatest` when the "latest" release is different than the newest version from the tags. ### URL guidelines @@ -61,77 +61,95 @@ When in doubt, start with one of these examples instead of copy-pasting a `livec ### File names +When matching the version from a file name on an HTML page, we often restrict matching to `href` attributes. `href=.*?` will match the opening delimiter (`"`, `'`) as well as any part of the URL before the file name. + ```ruby - livecheck do - url "https://www.example.com/downloads/" - regex(/href=.*?example[._-]v?(\d+(?:\.\d+)+)\.t/i) - end +livecheck do + url "https://www.example.com/downloads/" + regex(/href=.*?example[._-]v?(\d+(?:\.\d+)+)\.t/i) +end ``` -When matching the version from a file name on an HTML page, we often restrict matching to `href` attributes. `href=.*?` will match the opening delimiter (`"`, `'`) as well as any part of the URL before the file name. - We sometimes make this more explicit to exclude unwanted matches. URLs with a preceding path can use `href=.*?/` and others can use `href=["']?`. For example, this is necessary when the page also contains unwanted files with a longer prefix (`another-example-1.2.tar.gz`). ### Version directories +When checking a directory listing page, sometimes files are separated into version directories (e.g. `1.2.3/`). In this case, we must identify versions from the directory names. + ```ruby - livecheck do - url "https://www.example.com/releases/example/" - regex(%r{href=["']?v?(\d+(?:\.\d+)+)/?["' >]}i) - end +livecheck do + url "https://www.example.com/releases/example/" + regex(%r{href=["']?v?(\d+(?:\.\d+)+)/?["' >]}i) +end ``` -When checking a directory listing page, sometimes files are separated into version directories (e.g. `1.2.3/`). In this case, we must identify versions from the directory names. - ### Git tags +When the `stable` URL uses the `Git` strategy, the following example will only match tags like `1.2`/`v1.2`, etc. + ```ruby - livecheck do - url :stable - regex(/^v?(\d+(?:\.\d+)+)$/i) - end +livecheck do + url :stable + regex(/^v?(\d+(?:\.\d+)+)$/i) +end ``` -When the `stable` URL uses the `Git` strategy, the regex above will only match tags like `1.2`/`v1.2`, etc. - If tags include the software name as a prefix (e.g. `example-1.2.3`), it's easy to modify the regex accordingly: `/^example[._-]v?(\d+(?:\.\d+)+)$/i` -### `PageMatch` `strategy` block +### `strategy` blocks + +If the upstream version format needs to be manipulated to match the formula/cask format, a `strategy` block can be used instead of a `regex`. + +#### `PageMatch` `strategy` block + +In the example below, we're converting a date format like `2020-01-01` into `20200101`. ```ruby - livecheck do - url :homepage - regex(/href=.*?example[._-]v?(\d{4}-\d{2}-\d{2})\.t/i) - strategy :page_match do |page, regex| - page.scan(regex).map { |match| match&.first&.gsub(/\D/, "") } - end +livecheck do + url :homepage + strategy :page_match do |page| + page.scan(/href=.*?example[._-]v?(\d{4}-\d{2}-\d{2})\.t/i) + .map { |match| match&.first&.gsub(/\D/, "") } end +end ``` -When necessary, a `strategy` block allows us to have greater flexibility in how upstream version information is matched and processed. Currently, they're only used when the upstream version format needs to be manipulated to match the formula/cask format. In the example above, we're converting a date format like `2020-01-01` into `20200101`. - The `PageMatch` `strategy` block style seen here also applies to any strategy that uses `PageMatch` internally. -### `Git` `strategy` block +#### `Git` `strategy` block + +A `strategy` block for `Git` is a bit different, as the block receives an array of tag strings instead of a page content string. Similar to the `PageMatch` example, this is converting tags with a date format like `2020-01-01` into `20200101`. ```ruby - livecheck do - url :stable - regex(/^(\d{4}-\d{2}-\d{2})$/i) - strategy :git do |tags, regex| - tags.map { |tag| tag[regex, 1]&.gsub(/\D/, "") }.compact - end +livecheck do + url :stable + strategy :git do |tags| + tags.map { |tag| tag[/^(\d{4}-\d{2}-\d{2})$/i, 1]&.gsub(/\D/, "") }.compact end +end ``` -A `strategy` block for `Git` is a bit different, as the block receives an array of tag strings instead of a page content string. Similar to the `PageMatch` example, this is converting tags with a date format like `2020-01-01` into `20200101`. +#### `Sparkle` `strategy` block + +A `strategy` block for `Sparkle` receives an `item` which has methods for the `short_version`, `version`, `url` and `title`. -### Skip +The default pattern for the `Sparkle` strategy is `"#{item.short_version},#{item.version}"` if both are set. In the example below, the `url` also includes a download ID which is needed: ```ruby - livecheck do - skip "No version information available" +livecheck do + url "https://www.example.com/example.xml" + strategy :sparkle do |item| + "#{item.short_version},#{item.version}:#{item.url[%r{/(\d+)/[^/]+\.zip}i, 1]}" end +end ``` +### `skip` + Livecheck automatically skips some formulae/casks for a number of reasons (deprecated, disabled, discontinued, etc.). However, on rare occasions we need to use a `livecheck` block to do a manual skip. The `skip` method takes a string containing a very brief reason for skipping. + +```ruby +livecheck do + skip "No version information available" +end +```
false
Other
Homebrew
brew
128aeba3a4d255c31066541f9828fe211b8e1f9d.json
Keg: fix alias and versioned symlink handling. Previously, `brew upgrade gcc@10` could get overzealous and remove the `LinkedKeg` record for `gcc@9`. This is bad because we then think `gcc@9` is unlinked when it is not and it causes a tonne of conflicts when trying to link `gcc@9` again. Instead, fix up the alias and versioned alias cleanup to be more precise and only delete the symlinks that point to the current `rack`, `opt_record` or `linked_keg_record` and unify the logic so it's performed consistently. While we're here: - don't `remove_old_aliases` every time we try to unlink a directory but just perform it once per `unlink` operation - remove the linked keg record on `uninstall`
Library/Homebrew/keg.rb
@@ -301,28 +301,16 @@ def remove_old_aliases # versioned aliases are handled below next if a.match?(/.+@./) - alias_opt_symlink = opt/a - if alias_opt_symlink.symlink? && alias_opt_symlink.exist? - alias_opt_symlink.delete if alias_opt_symlink.realpath == opt_record.realpath - elsif alias_opt_symlink.symlink? || alias_opt_symlink.exist? - alias_opt_symlink.delete - end - - alias_linkedkegs_symlink = linkedkegs/a - alias_linkedkegs_symlink.delete if alias_linkedkegs_symlink.symlink? || alias_linkedkegs_symlink.exist? + remove_alias_symlink(opt/a, opt_record) + remove_alias_symlink(linkedkegs/a, linked_keg_record) end Pathname.glob("#{opt_record}@*").each do |a| a = a.basename.to_s next if aliases.include?(a) - alias_opt_symlink = opt/a - if alias_opt_symlink.symlink? && alias_opt_symlink.exist? && rack == alias_opt_symlink.realpath.parent - alias_opt_symlink.delete - end - - alias_linkedkegs_symlink = linkedkegs/a - alias_linkedkegs_symlink.delete if alias_linkedkegs_symlink.symlink? || alias_linkedkegs_symlink.exist? + remove_alias_symlink(opt/a, rack) + remove_alias_symlink(linkedkegs/a, rack) end end @@ -341,6 +329,7 @@ def uninstall path.rmtree path.parent.rmdir_if_possible remove_opt_record if optlinked? + remove_linked_keg_record if linked? remove_old_aliases remove_oldname_opt_record rescue Errno::EACCES, Errno::ENOTEMPTY @@ -377,12 +366,12 @@ def unlink(**options) dst.uninstall_info if dst.to_s.match?(INFOFILE_RX) dst.unlink - remove_old_aliases Find.prune if src.directory? end end unless options[:dry_run] + remove_old_aliases remove_linked_keg_record if linked? dirs.reverse_each(&:rmdir_if_possible) end @@ -659,6 +648,14 @@ def make_relative_symlink(dst, src, **options) raise LinkError.new(self, src.relative_path_from(path), dst, e) end + def remove_alias_symlink(alias_symlink, alias_match_path) + if alias_symlink.symlink? && alias_symlink.exist? + alias_symlink.delete if alias_symlink.realpath == alias_match_path.realpath + elsif alias_symlink.symlink? || alias_symlink.exist? + alias_symlink.delete + end + end + protected # symlinks the contents of path+relative_dir recursively into #{HOMEBREW_PREFIX}/relative_dir
false
Other
Homebrew
brew
591e9d6a52559c8d0e95140bd08c0666f9535705.json
dev-cmd/tap-new: fix output on newer versions of Git. Otherwise this prints to `stderr` to ask for configuration of the branch name: https://github.com/Homebrew/brew/pull/10323/checks?check_run_id=1701105141#step:5:51
Library/Homebrew/dev-cmd/tap-new.rb
@@ -148,7 +148,9 @@ def tap_new unless args.no_git? cd tap.path do - safe_system "git", "init" + # Would be nice to use --initial-branch here but it's not available in + # older versions of Git that we support. + safe_system "git", "-c", "init.defaultBranch=#{branch}", "init" safe_system "git", "add", "--all" safe_system "git", "commit", "-m", "Create #{tap} tap" safe_system "git", "branch", "-m", branch
false
Other
Homebrew
brew
9b4fea602b474100a5fd8ac8a9f059db8bcddd59.json
install: add workaround for rosetta2 path error msg It's possible the user's terminal emulator is running under rosetta2. Consequently, the i86_64 version of the ruby interpreter will be used. Likely, the right thing to do is simply install the arm64 version of the requested package. This can be accomplished using: arch -arm64 brew ... Fixes: #10313
Library/Homebrew/install.rb
@@ -32,12 +32,16 @@ def perform_build_from_source_checks(all_fatal: false) def check_prefix if (Hardware::CPU.intel? || Hardware::CPU.in_rosetta2?) && HOMEBREW_PREFIX.to_s == HOMEBREW_MACOS_ARM_DEFAULT_PREFIX - configuration = if Hardware::CPU.in_rosetta2? - "under Rosetta 2" + if Hardware::CPU.in_rosetta2? + configuration = "under Rosetta 2" + odie <<~EOS + Cannot install in Homebrew #{configuration} in ARM default prefix (#{HOMEBREW_PREFIX})! + Try `arch -arm64 brew install ...` + EOS else - "on Intel processor" + configuration = "on Intel processor" + odie "Cannot install in Homebrew #{configuration} in ARM default prefix (#{HOMEBREW_PREFIX})!" end - odie "Cannot install in Homebrew #{configuration} in ARM default prefix (#{HOMEBREW_PREFIX})!" elsif Hardware::CPU.arm? && HOMEBREW_PREFIX.to_s == HOMEBREW_DEFAULT_PREFIX odie <<~EOS Cannot install in Homebrew on ARM processor in Intel default prefix (#{HOMEBREW_PREFIX})!
false
Other
Homebrew
brew
7592f568f13bfa9e5d5868a4880ba64146aac884.json
sorbet: Update RBI files. Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow.
Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi
@@ -5346,6 +5346,11 @@ class Cask::Config def vst_plugindir=(path); end end +class Cask::Config + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + class Cask::DSL::Caveats def depends_on_java(*args); end @@ -7698,6 +7703,11 @@ class Homebrew::CLI::Parser extend ::T::Private::Methods::SingletonMethodHooks end +module Homebrew::Completions + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + module Homebrew::EnvConfig extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks @@ -7834,6 +7844,11 @@ class Homebrew::FormulaCreator extend ::T::Private::Methods::SingletonMethodHooks end +module Homebrew::Livecheck::SkipConditions + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + class Homebrew::Livecheck::Strategy::HeaderMatch extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks @@ -7865,6 +7880,11 @@ module Homebrew::Livecheck extend ::T::Private::Methods::SingletonMethodHooks end +module Homebrew::Settings + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + class Homebrew::Style::LineLocation extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks
false
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cli/named_args.rb
@@ -188,6 +188,18 @@ def to_kegs_to_casks(only: parent&.only_formula_or_cask, ignore_unavailable: nil .map(&:freeze).freeze end + sig { returns(T::Array[Tap]) } + def to_taps + @to_taps ||= downcased_unique_named.map { |name| Tap.fetch name }.uniq.freeze + end + + sig { returns(T::Array[Tap]) } + def to_installed_taps + @to_installed_taps ||= to_taps.each do |tap| + raise TapUnavailableError, tap.name unless tap.installed? + end.uniq.freeze + end + sig { returns(T::Array[String]) } def homebrew_tap_cask_names downcased_unique_named.grep(HOMEBREW_CASK_TAP_CASK_REGEX)
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cli/parser.rb
@@ -126,9 +126,9 @@ def initialize(&block) @conflicts = [] @switch_sources = {} @processed_options = [] + @named_args_type = nil @max_named_args = nil @min_named_args = nil - @min_named_type = nil @hide_from_man_page = false @formula_options = false @@ -355,33 +355,71 @@ def formula_options @formula_options = true end + sig do + params( + type: T.any(Symbol, T::Array[String], T::Array[Symbol]), + number: T.nilable(Integer), + min: T.nilable(Integer), + max: T.nilable(Integer), + ).void + end + def named_args(type = nil, number: nil, min: nil, max: nil) + if number.present? && (min.present? || max.present?) + raise ArgumentError, "Do not specify both `number` and `min` or `max`" + end + + if type == :none && (number.present? || min.present? || max.present?) + raise ArgumentError, "Do not specify both `number`, `min` or `max` with `named_args :none`" + end + + @named_args_type = type + + if type == :none + @max_named_args = 0 + elsif number.present? + @min_named_args = @max_named_args = number + elsif min.present? || max.present? + @min_named_args = min + @max_named_args = max + end + end + def max_named(count) + # TODO: (2.8) uncomment for the next major/minor release + # odeprecated "`max_named`", "`named_args max:`" + raise TypeError, "Unsupported type #{count.class.name} for max_named" unless count.is_a?(Integer) @max_named_args = count end def min_named(count_or_type) + # TODO: (2.8) uncomment for the next major/minor release + # odeprecated "`min_named`", "`named_args min:`" + case count_or_type when Integer @min_named_args = count_or_type - @min_named_type = nil + @named_args_type = nil when Symbol @min_named_args = 1 - @min_named_type = count_or_type + @named_args_type = count_or_type else raise TypeError, "Unsupported type #{count_or_type.class.name} for min_named" end end def named(count_or_type) + # TODO: (2.8) uncomment for the next major/minor release + # odeprecated "`named`", "`named_args`" + case count_or_type when Integer @max_named_args = @min_named_args = count_or_type - @min_named_type = nil + @named_args_type = nil when Symbol @max_named_args = @min_named_args = 1 - @min_named_type = count_or_type + @named_args_type = count_or_type else raise TypeError, "Unsupported type #{count_or_type.class.name} for named" end @@ -480,15 +518,15 @@ def check_constraint_violations def check_named_args(args) exception = if @min_named_args && args.size < @min_named_args - case @min_named_type - when :cask - Cask::CaskUnspecifiedError - when :formula - FormulaUnspecifiedError - when :formula_or_cask - FormulaOrCaskUnspecifiedError - when :keg - KegUnspecifiedError + if @named_args_type.present? + types = @named_args_type.is_a?(Array) ? @named_args_type : [@named_args_type] + if types.any? { |arg| arg.is_a? String } + MinNamedArgumentsError.new(@min_named_args) + else + list = types.map { |type| type.to_s.tr("_", " ") } + list = list.to_sentence two_words_connector: " or ", last_word_connector: " or " + UsageError.new("this command requires a #{list} argument") + end else MinNamedArgumentsError.new(@min_named_args) end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/--cache.rb
@@ -32,6 +32,8 @@ def __cache_args description: "Only show cache files for casks." conflicts "--build-from-source", "--force-bottle" conflicts "--formula", "--cask" + + named_args [:formula, :cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/--caskroom.rb
@@ -17,6 +17,8 @@ def __caskroom_args If <cask> is provided, display the location in the Caskroom where <cask> would be installed, without any sort of versioned directory as the last path. EOS + + named_args :cask end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/--cellar.rb
@@ -17,6 +17,8 @@ def __cellar_args If <formula> is provided, display the location in the Cellar where <formula> would be installed, without any sort of versioned directory as the last path. EOS + + named_args :formula end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/--env.rb
@@ -27,6 +27,8 @@ def __env_args "or `--shell=auto` to detect the current shell." switch "--plain", description: "Generate plain output even when piped." + + named_args :formula end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/--prefix.rb
@@ -25,6 +25,8 @@ def __prefix_args EOS switch "--unbrewed", description: "List files in Homebrew's prefix not installed by Homebrew." + + named_args :formula end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/--repository.rb
@@ -18,6 +18,8 @@ def __repository_args If <user>`/`<repo> are provided, display where tap <user>`/`<repo>'s directory is located. EOS + + named_args :tap end end @@ -27,7 +29,7 @@ def __repository if args.no_named? puts HOMEBREW_REPOSITORY else - puts args.named.map { |tap| Tap.fetch(tap).path } + puts args.named.to_taps.map(&:path) end end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/--version.rb
@@ -18,7 +18,7 @@ def __version_args (if tapped) to standard output. EOS - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/analytics.rb
@@ -27,7 +27,7 @@ def analytics_args Regenerate the UUID used for Homebrew's analytics. EOS - max_named 1 + named_args %w[state on off regenerate-uuid], max: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/autoremove.rb
@@ -18,7 +18,7 @@ def autoremove_args switch "-n", "--dry-run", description: "List what would be uninstalled, but do not actually uninstall anything." - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/cleanup.rb
@@ -31,6 +31,8 @@ def cleanup_args "If you want to delete those too: `rm -rf \"$(brew --cache)\"`" switch "--prune-prefix", description: "Only prune the symlinks and directories from the prefix and remove no other files." + + named_args [:formula, :cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/commands.rb
@@ -22,7 +22,7 @@ def commands_args depends_on: "--quiet", description: "Include aliases of internal commands." - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/completions.rb
@@ -25,7 +25,7 @@ def completions_args Link or unlink Homebrew's completions. EOS - max_named 1 + named_args %w[state link unlink], max: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/config.rb
@@ -19,7 +19,7 @@ def config_args a bug report, you will be required to provide this information. EOS - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/deps.rb
@@ -66,6 +66,8 @@ def deps_args conflicts "--installed", "--all" conflicts "--formula", "--cask" formula_options + + named_args [:formula, :cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/desc.rb
@@ -34,7 +34,8 @@ def desc_args "it is interpreted as a regular expression." conflicts "--search", "--name", "--description" - min_named 1 + + named_args :formula end end @@ -50,10 +51,14 @@ def desc end results = if search_type.nil? + raise FormulaUnspecifiedError if args.no_named? + desc = {} args.named.to_formulae.each { |f| desc[f.full_name] = f.desc } Descriptions.new(desc) else + raise UsageError, "this command requires a search term" if args.no_named? + query = args.named.join(" ") string_or_regex = query_regexp(query) CacheStoreDatabase.use(:descriptions) do |db|
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/doctor.rb
@@ -27,6 +27,8 @@ def doctor_args "if provided as arguments." switch "-D", "--audit-debug", description: "Enable debugging and profiling of audit methods." + + named_args :diagnostic_check end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/fetch.rb
@@ -58,7 +58,7 @@ def fetch_args conflicts "--cask", "--build-bottle" conflicts "--cask", "--force-bottle" - min_named :formula_or_cask + named_args [:formula, :cask], min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/gist-logs.rb
@@ -33,7 +33,7 @@ def gist_logs_args description: "The Gist will be marked private and will not appear in listings but will "\ "be accessible with its link." - named :formula + named_args :formula, number: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/home.rb
@@ -23,6 +23,8 @@ def home_args switch "--cask", "--casks", description: "Treat all named arguments as casks." conflicts "--formula", "--cask" + + named_args [:formula, :cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/info.rb
@@ -68,6 +68,8 @@ def info_args conflicts "--formula", "--cask" conflicts "--installed", "--all" + + named_args [:formula, :cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/install.rb
@@ -125,7 +125,8 @@ def install_args conflicts "--ignore-dependencies", "--only-dependencies" conflicts "--build-from-source", "--build-bottle", "--force-bottle" - min_named :formula_or_cask + + named_args [:formula, :cask], min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/leaves.rb
@@ -18,7 +18,7 @@ def leaves_args List installed formulae that are not dependencies of another installed formula. EOS - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/link.rb
@@ -29,7 +29,7 @@ def link_args switch "-f", "--force", description: "Allow keg-only formulae to be linked." - min_named :keg + named_args :installed_formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/list.rb
@@ -72,6 +72,8 @@ def list_args conflicts "--full-name", flag conflicts "--cask", flag end + + named_args [:installed_formula, :installed_cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/log.rb
@@ -30,7 +30,8 @@ def log_args description: "Print only a specified number of commits." conflicts "-1", "--max-count" - max_named 1 + + named_args :formula, max: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/migrate.rb
@@ -22,7 +22,7 @@ def migrate_args description: "Treat installed <formula> and provided <formula> as if they are from "\ "the same taps and migrate them anyway." - min_named :formula + named_args :installed_formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/missing.rb
@@ -24,6 +24,8 @@ def missing_args comma_array "--hide", description: "Act as if none of the specified <hidden> are installed. <hidden> should be "\ "a comma-separated list of formulae." + + named_args :formula end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/options.rb
@@ -29,6 +29,8 @@ def options_args description: "Show options for the specified <command>." conflicts "--installed", "--all", "--command" + + named_args :formula end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/outdated.rb
@@ -42,6 +42,8 @@ def outdated_args conflicts "--quiet", "--verbose", "--json" conflicts "--formula", "--cask" + + named_args [:formula, :cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/pin.rb
@@ -19,7 +19,7 @@ def pin_args issuing the `brew upgrade` <formula> command. See also `unpin`. EOS - min_named :formula + named_args :installed_formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/postinstall.rb
@@ -19,7 +19,7 @@ def postinstall_args Rerun the post-install steps for <formula>. EOS - min_named :keg + named_args :installed_formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/readall.rb
@@ -24,6 +24,8 @@ def readall_args description: "Verify any alias symlinks in each tap." switch "--syntax", description: "Syntax-check all of Homebrew's Ruby files (if no `<tap>` is passed)." + + named_args :tap end end @@ -41,7 +43,7 @@ def readall taps = if args.no_named? Tap else - args.named.map { |t| Tap.fetch(t) } + args.named.to_installed_taps end taps.each do |tap| Homebrew.failed = true unless Readall.valid_tap?(tap, options)
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/reinstall.rb
@@ -75,7 +75,8 @@ def reinstall_args cask_options conflicts "--build-from-source", "--force-bottle" - min_named :formula_or_cask + + named_args [:formula, :cask], min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/search.rb
@@ -66,6 +66,9 @@ def search_args conflicts("--desc", "--pull-request") conflicts(*package_manager_switches) + + # TODO: (2.9) uncomment when the `odeprecated`/`odisabled` for `brew search` with no arguments is removed + # named_args min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/tap-info.rb
@@ -24,6 +24,8 @@ def tap_info_args description: "Print a JSON representation of <tap>. Currently the default and only accepted "\ "value for <version> is `v1`. See the docs for examples of using the JSON "\ "output: <https://docs.brew.sh/Querying-Brew>" + + named_args :tap end end @@ -33,9 +35,7 @@ def tap_info taps = if args.installed? Tap else - args.named.sort.map do |name| - Tap.fetch(name) - end + args.named.to_taps end if args.json
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/tap.rb
@@ -41,7 +41,7 @@ def tap_args switch "--list-pinned", description: "List all pinned taps." - max_named 2 + named_args :tap, max: 2 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/uninstall.rb
@@ -40,7 +40,7 @@ def uninstall_args description: "Treat all named arguments as casks." conflicts "--formula", "--cask" - min_named :formula_or_cask + named_args [:installed_formula, :installed_cask], min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/unlink.rb
@@ -24,7 +24,7 @@ def unlink_args description: "List files which would be unlinked without actually unlinking or "\ "deleting any files." - min_named :keg + named_args :installed_formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/unpin.rb
@@ -19,7 +19,7 @@ def unpin_args See also `pin`. EOS - min_named :formula + named_args :installed_formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/untap.rb
@@ -17,15 +17,14 @@ def untap_args Remove a tapped formula repository. EOS - min_named 1 + named_args :tap, min: 1 end end def untap args = untap_args.parse - args.named.each do |tapname| - tap = Tap.fetch(tapname) + args.named.to_installed_taps.each do |tap| odie "Untapping #{tap} is not allowed" if tap.core_tap? installed_tap_formulae = Formula.installed.select { |formula| formula.tap == tap }
true