From 33fccb46ca109bfcdbdbce78e7a06a4c22bbd31c Mon Sep 17 00:00:00 2001
From: hyuraku <32809703+hyuraku@users.noreply.github.com>
Date: Thu, 3 Dec 2020 21:57:42 +0900
Subject: [PATCH] add two flag to deps --installed

---
 Library/Homebrew/cmd/deps.rb | 25 ++++++++++++++++++++++---
 docs/Manpage.md              |  4 ++++
 manpages/brew.1              |  8 ++++++++
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb
index 42e50c984a..8186ab1f47 100644
--- a/Library/Homebrew/cmd/deps.rb
+++ b/Library/Homebrew/cmd/deps.rb
@@ -57,8 +57,15 @@ module Homebrew
              description: "Switch into the mode used by the `--all` option, but only list dependencies "\
                           "for each provided <formula>, one formula per line. This is used for "\
                           "debugging the `--installed`/`--all` display mode."
+      switch "--formula", "--formulae",
+             depends_on:  "--installed",
+             description: "Treat all named arguments as formulae."
+      switch "--cask", "--casks",
+             depends_on:  "--installed",
+             description: "Treat all named arguments as casks."
 
       conflicts "--installed", "--all"
+      conflicts "--formula", "--cask"
       formula_options
     end
   end
@@ -82,7 +89,13 @@ module Homebrew
       dependents = if args.named.present?
         sorted_dependents(args.named.to_formulae_and_casks)
       elsif args.installed?
-        sorted_dependents(Formula.installed + Cask::Caskroom.casks(config: Cask::Config.from_args(args)))
+        if args.formula? && !args.cask?
+          sorted_dependents(Formula.installed)
+        elsif args.cask? && !args.formula?
+          sorted_dependents(Cask::Caskroom.casks(config: Cask::Config.from_args(args)))
+        else
+          sorted_dependents(Formula.installed + Cask::Caskroom.casks(config: Cask::Config.from_args(args)))
+        end
       else
         raise FormulaUnspecifiedError
       end
@@ -100,8 +113,14 @@ module Homebrew
     if args.no_named?
       raise FormulaUnspecifiedError unless args.installed?
 
-      puts_deps sorted_dependents(Formula.installed + Cask::Caskroom.casks(config: Cask::Config.from_args(args))),
-                recursive: recursive, args: args
+      sorted_dependents_formulae_and_casks = if args.formula? && !args.cask?
+        sorted_dependents(Formula.installed)
+      elsif args.cask? && !args.formula?
+        sorted_dependents(Cask::Caskroom.casks(config: Cask::Config.from_args(args)))
+      else
+        sorted_dependents(Formula.installed + Cask::Caskroom.casks(config: Cask::Config.from_args(args)))
+      end
+      pus_deps sorted_dependents_formulae_and_casks, recursive: recursive, args: args
       return
     end
 
diff --git a/docs/Manpage.md b/docs/Manpage.md
index 0d7b130b28..27525453db 100644
--- a/docs/Manpage.md
+++ b/docs/Manpage.md
@@ -129,6 +129,10 @@ show the intersection of dependencies for each formula.
   List dependencies for all available formulae.
 * `--for-each`:
   Switch into the mode used by the `--all` option, but only list dependencies for each provided *`formula`*, one formula per line. This is used for debugging the `--installed`/`--all` display mode.
+* `--formula`:
+  Treat all named arguments as formulae.
+* `--cask`:
+  Treat all named arguments as casks.
 
 ### `desc` [*`options`*] (*`text`*|`/`*`text`*`/`|*`formula`*)
 
diff --git a/manpages/brew.1 b/manpages/brew.1
index 684615bdd0..2e6304a461 100644
--- a/manpages/brew.1
+++ b/manpages/brew.1
@@ -152,6 +152,14 @@ List dependencies for all available formulae\.
 \fB\-\-for\-each\fR
 Switch into the mode used by the \fB\-\-all\fR option, but only list dependencies for each provided \fIformula\fR, one formula per line\. This is used for debugging the \fB\-\-installed\fR/\fB\-\-all\fR display mode\.
 .
+.TP
+\fB\-\-formula\fR
+Treat all named arguments as formulae\.
+.
+.TP
+\fB\-\-cask\fR
+Treat all named arguments as casks\.
+.
 .SS "\fBdesc\fR [\fIoptions\fR] (\fItext\fR|\fB/\fR\fItext\fR\fB/\fR|\fIformula\fR)"
 Display \fIformula\fR\'s name and one\-line description\. Formula descriptions are cached; the cache is created on the first search, making that search slower than subsequent ones\.
 .
-- 
GitLab