From 0bb8a061932238596572cb3054ecb70f6f5a1c86 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Wed, 3 Aug 2022 17:01:52 +0100 Subject: [PATCH] dev-cmd/contributions: Revert to `--repositories` flag - This doesn't require "all" to be specified as part of the command, it's the default, so usage is now just: ``` $ brew contributions "Issy Long" $ brew contributions "Issy Long" --repositories=brew,core $ brew contributions me@issyl0.co.uk --repositories=cask,bundle ``` - As we discussed in the PR review before, `comma_array` doesn't allow two names, so we can't (yet) do `comma_array "--repositories", "--repos"` like we can with `flag`. That's an enhancement for the future if we want to make the flags here less verbose. But now that "all" is the default, maybe less necessary. --- Library/Homebrew/dev-cmd/contributions.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/dev-cmd/contributions.rb b/Library/Homebrew/dev-cmd/contributions.rb index f600c3ca30..b479f75d38 100755 --- a/Library/Homebrew/dev-cmd/contributions.rb +++ b/Library/Homebrew/dev-cmd/contributions.rb @@ -17,24 +17,24 @@ module Homebrew sig { returns(CLI::Parser) } def contributions_args Homebrew::CLI::Parser.new do - usage_banner "`contributions` " + usage_banner "`contributions` " description <<~EOS Contributions to Homebrew repos for a user. The first argument is a name (e.g. "BrewTestBot") or an email address (e.g. "brewtestbot@brew.sh"). - - The second argument is a comma-separated list of repos to search. - Specify to search all repositories. - Supported repositories: #{SUPPORTED_REPOS.join(", ")}. EOS + comma_array "--repositories", + description: "Specify a comma-separated (no spaces) list of repositories to search. " \ + "Supported repositories: #{SUPPORTED_REPOS.join(", ")}. " \ + "Omitting this flag, or specifying `--repositories=all`, will search all repositories." flag "--from=", description: "Date (ISO-8601 format) to start searching contributions." flag "--to=", description: "Date (ISO-8601 format) to stop searching contributions." - named_args min: 2, max: 2 + named_args min: 1, max: 1 end end @@ -45,8 +45,8 @@ module Homebrew commits = 0 coauthorships = 0 - all_repos = args.named.last == "all" - repos = all_repos ? SUPPORTED_REPOS : args.named.last.split(",") + all_repos = args.repositories.nil? || args.repositories.include?("all") + repos = all_repos ? SUPPORTED_REPOS : args.repositories repos.each do |repo| if SUPPORTED_REPOS.exclude?(repo)